Release a snapshot artifact for a PR #171
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: Release a snapshot artifact for a PR | |
on: | |
workflow_run: | |
workflows: ['CI'] | |
branches-ignore: ['dependabot/**'] | |
types: [completed] | |
jobs: | |
release-snapshot-artifact: | |
runs-on: ubuntu-latest | |
if: ${{ github.event.pull_request.user.login != 'dependabot[bot]' && github.event.workflow_run.conclusion == 'success' }} | |
steps: | |
- name: Download PR_NUMBER | |
uses: dawidd6/action-download-artifact@268677152d06ba59fcec7a7f0b5d961b6ccd7e1e # v2.28.0 | |
with: | |
run_id: ${{github.event.workflow_run.id }} | |
name: PR_NUMBER | |
path: . | |
- name: Extract PR number | |
id: extract-pr-number | |
run: | | |
pr_number=$(cat ./PR_NUMBER) | |
echo "PR_NUMBER=$pr_number" >> $GITHUB_OUTPUT | |
- name: Checkout project | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | |
- name: Checkout PR | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: gh pr checkout ${{ steps.extract-pr-number.outputs.PR_NUMBER }} | |
- name: Download dist folder | |
uses: dawidd6/action-download-artifact@268677152d06ba59fcec7a7f0b5d961b6ccd7e1e # v2.28.0 | |
with: | |
run_id: ${{github.event.workflow_run.id }} | |
name: dist | |
path: dist | |
- name: Remove `dist` from `.gitignore` | |
run: sed -i -E 's|^/?dist/?||g' .gitignore | |
- name: Create snapshot branch | |
uses: alejandrohdezma/actions/commit-and-push@v1 | |
with: | |
message: 'Release snapshot for #${{ steps.extract-pr-number.outputs.PR_NUMBER }}' | |
force-push: 'true' | |
branch: snapshots/${{ steps.extract-pr-number.outputs.PR_NUMBER }} | |
- name: Create Comment | |
uses: marocchino/sticky-pull-request-comment@efaaab3fd41a9c3de579aba759d2552635e590fd # v2.8.0 | |
with: | |
recreate: true | |
header: snapshot | |
number: ${{ steps.extract-pr-number.outputs.PR_NUMBER }} | |
message: | | |
A snapshot release has been created as `snapshots/${{ steps.extract-pr-number.outputs.PR_NUMBER }}`. | |
You can test it out with: | |
```yaml | |
uses: scala-steward-org/scala-steward-action@snapshots/${{ steps.extract-pr-number.outputs.PR_NUMBER }} | |
``` | |
It will be automatically recreated on any change to this PR. |