-
-
Notifications
You must be signed in to change notification settings - Fork 216
chore(ci): add update-lockfiles automation wf #1081
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,118 @@ | ||
| name: Update lockfiles | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| schedule: | ||
| - cron: "0 4 * * 1" | ||
|
|
||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| update-lockfiles: | ||
| name: Refresh mix.lock files | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 15 | ||
| steps: | ||
| - name: Get auth token | ||
| id: token | ||
| uses: actions/create-github-app-token@5d869da34e18e7287c1daad50e0b8ea0f506ce69 # v1.11.0 | ||
| with: | ||
| app-id: ${{ vars.SENTRY_RELEASE_BOT_CLIENT_ID }} | ||
| private-key: ${{ secrets.SENTRY_RELEASE_BOT_PRIVATE_KEY }} | ||
|
|
||
| - name: Check out this repository | ||
| uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 | ||
| with: | ||
| token: ${{ steps.token.outputs.token }} | ||
|
|
||
| - name: Setup Elixir and Erlang | ||
| uses: erlef/setup-beam@fc68ffb90438ef2936bbb3251622353b3dcb2f93 # v1.24.0 | ||
| with: | ||
| elixir-version: "1.18" | ||
| otp-version: "27.2" | ||
|
|
||
| - name: Refresh lockfiles | ||
| run: | | ||
| for lock in mix.lock test_integrations/*/mix.lock; do | ||
| dir=$(dirname "$lock") | ||
| echo "==> Refreshing mix.lock in $dir" | ||
| (cd "$dir" && mix deps.update --all) | ||
| done | ||
|
|
||
| - name: Configure git | ||
| run: | | ||
| git config user.name 'github-actions[bot]' | ||
| git config user.email '41898282+github-actions[bot]@users.noreply.github.com' | ||
|
|
||
| - name: Create branch | ||
| id: create-branch | ||
| run: | | ||
| # Stage first, then diff the index against HEAD: plain `git diff` ignores | ||
| # untracked files, so a brand-new project's lock would look unchanged. | ||
| git add mix.lock 'test_integrations/*/mix.lock' | ||
|
|
||
| if git diff --cached --quiet; then | ||
| echo "No lockfile changes; nothing to do." | ||
| echo "changed=false" >> "$GITHUB_OUTPUT" | ||
| exit 0 | ||
| fi | ||
|
|
||
| COMMIT_TITLE="chore(deps): Refresh mix.lock files" | ||
| BRANCH_NAME="deps/lockfiles-update-$(date +%Y-%m-%d)" | ||
|
|
||
| git checkout -B "$BRANCH_NAME" | ||
| git commit -m "$COMMIT_TITLE" | ||
| git push origin "$BRANCH_NAME" --force | ||
|
|
||
| echo "changed=true" >> "$GITHUB_OUTPUT" | ||
| echo "branch_name=$BRANCH_NAME" >> "$GITHUB_OUTPUT" | ||
| echo "commit_title=$COMMIT_TITLE" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Create pull request | ||
| if: steps.create-branch.outputs.changed == 'true' | ||
| uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 | ||
| env: | ||
| BRANCH_NAME: ${{ steps.create-branch.outputs.branch_name }} | ||
| COMMIT_TITLE: ${{ steps.create-branch.outputs.commit_title }} | ||
| with: | ||
| github-token: ${{ steps.token.outputs.token }} | ||
| script: | | ||
| const branchName = process.env.BRANCH_NAME; | ||
| const commitTitle = process.env.COMMIT_TITLE; | ||
| const prBody = `Automated weekly refresh of the committed \`mix.lock\` files via \`mix deps.update --all\`, keeping dependency pins current with the latest security patches allowed by each project's version constraints. | ||
|
|
||
| #skip-changelog | ||
|
|
||
| ## Action required | ||
| - If CI passes on this PR, it's safe to approve and merge. | ||
| - If CI fails, a dependency update broke something — investigate before merging. | ||
|
|
||
| _🤖 Automatically created by [.github/workflows/update_lockfiles.yml](https://github.com/getsentry/sentry-elixir/blob/master/.github/workflows/update_lockfiles.yml)._`.replace(/^ {12}/gm, ''); | ||
|
|
||
| // Close superseded lockfile PRs — they're now obsolete. | ||
| const existingPRs = await github.paginate(github.rest.pulls.list, { | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| state: 'open', | ||
| }); | ||
| for (const pr of existingPRs) { | ||
| if (pr.head.ref.startsWith('deps/lockfiles-update-')) { | ||
| await github.rest.pulls.update({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| pull_number: pr.number, | ||
| state: 'closed', | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| await github.rest.pulls.create({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| title: commitTitle, | ||
| head: branchName, | ||
| base: 'master', | ||
| body: prBody, | ||
| }); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.