Skip to content

Commit 9a65436

Browse files
authored
Merge pull request aws#7833 from stealthycoin/update-v2-lockfiles-action
Add a update-lockfiles github workflow
2 parents d8869ab + 6059af7 commit 9a65436

File tree

1 file changed

+85
-0
lines changed

1 file changed

+85
-0
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: Update lockfiles
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
ref:
7+
description: |
8+
Branch or ref to clone. This is where the lockfiles will be added and
9+
ultimately committed.
10+
required: true
11+
12+
dry-run:
13+
type: choice
14+
options:
15+
- "yes"
16+
- "no"
17+
default: "yes"
18+
description: |
19+
Dry run mode when enabled with the "yes" option will not commit or push
20+
the generated files.
21+
22+
23+
jobs:
24+
25+
update-lockfiles:
26+
runs-on: ${{ matrix.os }}
27+
strategy:
28+
fail-fast: false
29+
matrix:
30+
python-version: ["3.11"]
31+
os: [macOS-latest, windows-latest]
32+
33+
steps:
34+
- uses: actions/checkout@v3
35+
with:
36+
ref: ${{ github.event.inputs.ref }}
37+
- name: Set up Python ${{ matrix.python-version }}
38+
uses: actions/setup-python@v4
39+
with:
40+
python-version: ${{ matrix.python-version }}
41+
42+
- name: Install dependencies
43+
run: |
44+
python -m pip install -r requirements-test.txt
45+
# Windows and posix have different syntax for setting the env vars
46+
# in github actions so we need to duplicate the next step one for windows and
47+
# one for macOS. In order to do that we need to write variables by either using
48+
# >> $env:GITHUB_ENV or >>GITHUB_ENV depending on the OS.
49+
# In addition, on macOS writing a multiline value to $GITHUB_ENV
50+
# will result in failure. We need to use the multiline pattern:
51+
# echo VAR_NAME<<EOF >> $GITHUB_ENV
52+
# echo "multiline values" >> $GIHTUB_ENV
53+
# echo "EOF" >> $GITHUB_ENV
54+
- name: Regenerate windows files
55+
if: runner.os == 'Windows'
56+
run: |
57+
python scripts/regenerate-lock-files --show-files
58+
echo "CHANGES=$(git status --porcelain=v1)" >> $env:GITHUB_ENV
59+
- name: Regenerate lock files
60+
if: runner.os != 'Windows'
61+
run: |
62+
python scripts/regenerate-lock-files --show-files
63+
echo "CHANGES<<EOF" >> $GITHUB_ENV
64+
echo "CHANGES=$(git status --porcelain=v1)" >> $GITHUB_ENV
65+
echo "EOF" >> $GITHUB_ENV
66+
# If changes were created when running the regenerate-lock-files script
67+
# then the new lock files need to be commited and pushed to the branch.
68+
- name: Windows commit message
69+
if: runner.os == 'Windows'
70+
run: |
71+
echo "PLATFORMS=Windows" >> $env:GITHUB_ENV
72+
- name: Posix commit message
73+
if: runner.os != 'Windows'
74+
run: |
75+
echo "PLATFORMS=macOS and Linux" >> $GITHUB_ENV
76+
- name: git commit and push updated lock files
77+
if: github.event.inputs.dry-run == 'no' && env.CHANGES
78+
run: |
79+
git config --global user.name "Github Actions"
80+
git config --global user.email "<>"
81+
git fetch
82+
git add requirements
83+
git commit -m "Regenerate lock files for ${{ env.PLATFORMS }}"
84+
git pull --rebase
85+
git push

0 commit comments

Comments
 (0)