-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #431 from scala-steward-org/build/pr-snapshots
Create snapshot versions with changes in PRs
- Loading branch information
Showing
4 changed files
with
97 additions
and
8 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: npm | ||
directory: "/" | ||
schedule: | ||
interval: monthly | ||
time: "07:00" | ||
timezone: Europe/Madrid | ||
open-pull-requests-limit: 10 | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "monthly" | ||
- package-ecosystem: npm | ||
directory: "/" | ||
schedule: | ||
interval: monthly |
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
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
name: Release a snapshot artifact for a PR | ||
|
||
on: | ||
pull_request_target: | ||
types: | ||
- closed | ||
workflow_run: | ||
workflows: ["CI"] | ||
types: | ||
- completed | ||
|
||
jobs: | ||
release-snapshot-artifact: | ||
runs-on: ubuntu-latest | ||
if: > | ||
github.event_name == 'workflow_run' && | ||
github.event.workflow_run.event == 'pull_request' && | ||
github.event.workflow_run.conclusion == 'success' | ||
steps: | ||
- name: Checkout project | ||
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # v2.4.0 | ||
|
||
- name: Download dist folder | ||
uses: dawidd6/action-download-artifact@e6e25ac3a2b93187502a8be1ef9e9603afc34925 # v2.24.2 | ||
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: Extract PR number | ||
id: extract-pr-number | ||
run: | | ||
pr_number=$(cat ./dist/PR_NUMBER) | ||
echo "PR_NUMBER=$pr_number" >> $GITHUB_OUTPUT | ||
- 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: Find Comment | ||
uses: peter-evans/find-comment@f4499a714d59013c74a08789b48abe4b704364a0 # v2.1.0 | ||
id: find-comment | ||
with: | ||
issue-number: ${{ steps.extract-pr-number.outputs.PR_NUMBER }} | ||
comment-author: "github-actions[bot]" | ||
body-includes: A snapshot release | ||
|
||
- name: Create comment | ||
uses: peter-evans/create-or-update-comment@5adcb0bb0f9fb3f95ef05400558bdb3f329ee808 # v2.1.0 | ||
with: | ||
comment-id: ${{ steps.find-comment.outputs.comment-id }} | ||
issue-number: ${{ steps.extract-pr-number.outputs.PR_NUMBER }} | ||
edit-mode: replace | ||
body: | | ||
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. | ||
delete-pr-branch: | ||
runs-on: ubuntu-latest | ||
if: github.event_name == 'pull_request_target' | ||
steps: | ||
- name: Checkout project | ||
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # v2.4.0 | ||
|
||
- name: Remove snapshot branch | ||
run: git push origin -d snapshots/${{ github.event.number }} &>/dev/null |