Add MazeSolver package #3368
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Automatic Pull Request | |
on: | |
issues: | |
types: [opened, reopened] | |
env: | |
SWIFT_IMAGE: swift:6.0.1-jammy | |
jobs: | |
add: | |
runs-on: ubuntu-20.04 | |
if: contains(github.event.issue.labels.*.name, 'Add Package') | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Add Package to JSON | |
run: docker run --rm -e CI=true -e GH_BODY="$GH_BODY" -v "$PWD:/host" -w /host $SWIFT_IMAGE swift .github/add_package.swift | |
env: | |
GH_BODY: ${{ github.event.issue.body }} | |
- name: Validate JSON | |
run: docker run --rm -e CI=true -e GITHUB_TOKEN=$GITHUB_TOKEN -v "$PWD:/host" -w /host $SWIFT_IMAGE swift validate.swift | |
id: validate | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Check for Changes | |
run: bash .github/check_for_changes.sh | |
id: check | |
- name: Create Pull Request | |
id: cpr | |
if: steps.check.outputs.changes == 'true' | |
uses: peter-evans/create-pull-request@v3 | |
with: | |
add-paths: | | |
packages.json | |
commit-message: ${{ github.event.issue.title }} | |
title: ${{ github.event.issue.title }} | |
branch: spi-auto-${{ github.event.issue.number }} | |
delete-branch: true | |
body: | | |
Closes #${{ github.event.issue.number }} | |
## Original Message | |
${{ github.event.issue.body }} | |
committer: GitHub <[email protected]> | |
author: GitHub <[email protected]> | |
- name: Update Issue (Success) | |
if: steps.check.outputs.changes == 'true' | |
uses: actions/github-script@v3 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
github.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: 'Thank you! We will approve and add these packages with #${{ steps.cpr.outputs.pull-request-number }}.' | |
}) | |
- name: Update Issue (Failure) | |
if: ${{ failure() || steps.check.outputs.changes != 'true' }} | |
uses: actions/github-script@v3 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
github.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: 'It looks like there’s nothing to do here!\n\nThe package may [already be in the package list](https://github.com/SwiftPackageIndex/PackageList/blob/main/packages.json) or on the [denylist](https://github.com/SwiftPackageIndex/PackageList/blob/main/denylist.json). Or, if you submitted the wrong URL or there’s a typo, please close this issue and [start a new one](https://github.com/SwiftPackageIndex/PackageList/issues/new/choose).\n\n>Validate Error: ${{ steps.validate.outputs.validateError || 'None' }}' | |
}) | |
remove: | |
runs-on: ubuntu-20.04 | |
if: contains(github.event.issue.labels.*.name, 'Remove Package') | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Remove Package from JSON | |
run: docker run --rm -e CI=true -e GH_BODY="$GH_BODY" -e GH_ISSUE="$GH_ISSUE" -v "$PWD:/host" -w /host $SWIFT_IMAGE swift .github/remove_package.swift | |
env: | |
GH_BODY: ${{ github.event.issue.body }} | |
GH_ISSUE: ${{ github.event.issue.number }} | |
- name: Validate JSON | |
run: docker run --rm -e CI=true -e GITHUB_TOKEN=$GITHUB_TOKEN -v "$PWD:/host" -w /host $SWIFT_IMAGE swift validate.swift | |
id: validate | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Check for Changes | |
run: bash .github/check_for_changes.sh | |
id: check | |
- name: Create Pull Request | |
id: cpr | |
if: steps.check.outputs.changes == 'true' | |
uses: peter-evans/create-pull-request@v3 | |
with: | |
add-paths: | | |
packages.json | |
denylist.json | |
commit-message: ${{ github.event.issue.title }} | |
title: ${{ github.event.issue.title }} | |
branch: spi-auto-${{ github.event.issue.number }} | |
delete-branch: true | |
body: | | |
Closes #${{ github.event.issue.number }} | |
## Original Message | |
${{ github.event.issue.body }} | |
committer: GitHub <[email protected]> | |
author: GitHub <[email protected]> | |
- name: Update Issue (Success) | |
if: steps.check.outputs.changes == 'true' | |
uses: actions/github-script@v3 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
github.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: 'Thank you! We will approve and remove these packages with #${{ steps.cpr.outputs.pull-request-number }}.' | |
}) | |
- name: Update Issue (Failure) | |
if: ${{ failure() || steps.check.outputs.changes != 'true' }} | |
uses: actions/github-script@v3 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
github.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: 'Oh no! We were unable to detect any valid packages in your submission. If you submitted the wrong URL and would like to update it, please [open a new issue](https://github.com/SwiftPackageIndex/PackageList/issues/new/choose).\n\n>Validate Error: ${{ steps.validate.outputs.validateError || 'None' }}' | |
}) |