Repository navigation
163 lines (141 loc) · 5.96 KB
/
Copy pathupdate_lockfiles.yml
File metadata and controls
163 lines (141 loc) · 5.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
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 (${{ matrix.bucket }})
runs-on: ${{ matrix.os }}
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
# Each project's mix.exs picks its lockfile based on the running Elixir
# version (see `lockfile/1` in mix.exs), so one Elixir version per
# supported range is needed to refresh every lockfile bucket. Older OTP
# versions have no prebuilt binaries for newer Ubuntu images, so `os`
# mirrors the runner pinning in main.yml.
include:
- bucket: "1.13-1.14"
elixir: "1.13"
otp: "25.3"
os: ubuntu-24.04
- bucket: "1.15-1.17"
elixir: "1.17"
otp: "26.2"
os: ubuntu-24.04
- bucket: "1.18"
elixir: "1.18"
otp: "27.2"
os: ubuntu-latest
- bucket: "default"
elixir: "1.20.2-otp-29"
otp: "29.0.1"
os: ubuntu-latest
steps:
- name: Check out this repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
- name: Setup Elixir and Erlang
uses: erlef/setup-beam@54075bcc5e249e4758d363f27d099f55d843f124 # v1.24.1
with:
elixir-version: ${{ matrix.elixir }}
otp-version: ${{ matrix.otp }}
- name: Refresh lockfiles
id: refresh
run: scripts/refresh_lockfiles.sh "${{ matrix.bucket }}"
- name: Upload updated lockfiles
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: lockfiles-${{ matrix.bucket }}
path: ${{ steps.refresh.outputs.paths }}
if-no-files-found: error
create-pr:
name: Create pull request
needs: update-lockfiles
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: Download updated lockfiles
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6
with:
pattern: lockfiles-*
merge-multiple: true
- 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.
mapfile -t lockfiles < <(git ls-files -- 'mix.lock' 'mix-*.lock' 'test_integrations/*/mix.lock' 'test_integrations/*/mix-*.lock')
git add "${lockfiles[@]}"
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 (including the per-Elixir-version-range lockfiles) 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,
});