Test Positive #123
Workflow file for this run
This file contains hidden or 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: Test Positive | |
| on: | |
| workflow_dispatch: {} | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| setup: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Setup | |
| run: echo "Do setup" | |
| create-release: | |
| runs-on: ubuntu-latest | |
| continue-on-error: true | |
| needs: [setup] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v3 | |
| - id: create-release | |
| run: | | |
| release_name="${PREFIX}$(git rev-parse --short HEAD)" | |
| gh release create ${release_name} --prerelease --target ${{ github.sha }} --notes "Created by ${{ github.workflow }} (will be automatically deleted)." | |
| echo "name=${release_name}" > $GITHUB_OUTPUT | |
| echo "tag=$(gh release view ${release_name} --json tagName -q '.tagName')" >> $GITHUB_OUTPUT | |
| env: | |
| # Below is the main difference between this workflow's negative counterpart. | |
| # The action _will_ pick up a comment because the provided 'include_regex' will be able to match it. | |
| PREFIX: "v0.0.0-test.include." | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| outputs: | |
| name: ${{ steps.create-release.outputs.name }} | |
| tag: ${{ steps.create-release.outputs.tag }} | |
| assert: | |
| runs-on: ubuntu-latest | |
| needs: [create-release] | |
| outputs: | |
| comment-id: ${{ steps.fc.outputs.comment-id }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: ./ | |
| id: action | |
| with: | |
| tag: ${{ needs.create-release.outputs.tag }} | |
| include_regex: 'v0\.0\.0-test\.include\..*' # Should find a comment | |
| - name: debug | |
| run: | | |
| echo "${{ fromJSON(steps.action.outputs.result) }}" | |
| - name: Find Comment | |
| uses: peter-evans/find-comment@v3 | |
| id: fc | |
| with: | |
| issue-number: ${{ fromJSON(steps.action.outputs.result).comments[0].pull_request }} | |
| body-includes: ${{ needs.create-release.outputs.tag }} | |
| teardown: | |
| runs-on: ubuntu-latest | |
| needs: [create-release, assert] | |
| if: ${{ always() }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v3 | |
| - name: Delete Test Release + Tag | |
| if: needs.create-release.result == 'success' | |
| run: gh release delete ${{ needs.create-release.outputs.name }} --cleanup-tag | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - uses: octokit/[email protected] | |
| name: Delete Test Release Comment | |
| if: ${{ always() && needs.assert.outputs.comment-id != 0 }} | |
| with: | |
| route: DELETE /repos/{owner}/{repo}/issues/comments/{comment_id} | |
| owner: "${{ github.event.repository.owner.login }}" | |
| repo: "${{ github.event.repository.name }}" | |
| comment_id: ${{ needs.assert.outputs.comment-id }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |