Skip to content

Commit c321795

Browse files
committed
Add GH actions to update lockfiles
1 parent 137f8e7 commit c321795

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Submit PRs to update lockfiles
2+
3+
on:
4+
workflow_dispatch: # Allows manual triggering from the GitHub UI
5+
schedule:
6+
- cron: '0 4 * * *' # Daily at 4:00am UTC
7+
8+
jobs:
9+
update-lockfiles:
10+
if: github.event.repository.fork == true && github.repository == 'coreosbot-releng/coreos-assembler'
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
branch: [main]
15+
16+
permissions:
17+
pull-requests: write # Required to create a pull request
18+
contents: write # Required to rebase branches
19+
20+
steps:
21+
- name: Set up Python 3.12
22+
uses: actions/setup-python@v5
23+
24+
- name: Checkout repository
25+
uses: actions/checkout@v4
26+
with:
27+
# Required for 'peter-evans/create-pull-request' to push to a new branch
28+
fetch-depth: 0
29+
30+
- name: Synchronise the 'lockfiles-update-STREAM' branch with the upstream one
31+
env:
32+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33+
BRANCH: ${{ matrix.branch }}
34+
run: |
35+
TARGET_BRANCH=update-lockfiles-${BRANCH}
36+
echo "The target branch is '$TARGET_BRANCH'."
37+
38+
git remote add upstream https://github.com/coreos/coreos-assembler.git
39+
git fetch upstream
40+
if git ls-remote --heads origin "$TARGET_BRANCH" | grep -q "$TARGET_BRANCH"; then
41+
echo "Branch '$TARGET_BRANCH' exists on origin. Checking it out."
42+
git checkout "$TARGET_BRANCH"
43+
elif git rev-parse --verify --quiet "$TARGET_BRANCH" > /dev/null; then
44+
echo "Branch '$TARGET_BRANCH' exists locally. Checking it out."
45+
git checkout "$TARGET_BRANCH"
46+
else
47+
echo "Branch '$TARGET_BRANCH' does not exist. Creating it from upstream/${BRANCH}."
48+
if git rev-parse --verify --quiet "upstream/${BRANCH}" > /dev/null; then
49+
git checkout -b "$TARGET_BRANCH" upstream/${BRANCH}
50+
echo "Successfully created and checked out branch '$TARGET_BRANCH' from upstream/${BRANCH}."
51+
else
52+
echo "Error: upstream/${BRANCH} does not exist after fetch. Cannot create new branch."
53+
exit 1
54+
fi
55+
fi
56+
git rebase upstream/${BRANCH}
57+
git push --force origin "$TARGET_BRANCH"
58+
59+
- name: Update the lockfiles
60+
working-directory: ci/hermetic
61+
run: |
62+
git checkout update-lockfiles-${{ matrix.branch }}
63+
sudo apt-get update && sudo apt-get install -y python3-dnf
64+
pip3 install requests ruamel.yaml
65+
./update_artifacts_lockfile
66+
bash -x update_rpms_lockfile
67+
68+
- name: Create Pull Request
69+
uses: peter-evans/create-pull-request@v6
70+
with:
71+
token: ${{ secrets.UPDATE_LOCKFILES_PAT }}
72+
commit-message: 'feat(automated): Update the lockfiles'
73+
title: 'Automated: lockfiles updated'
74+
body: |
75+
This PR was automatically generated by the 'Submit PRs to update lockfiles' workflow.
76+
It updates the lockfiles.
77+
branch: update-lockfiles/${{ matrix.branch }}-candidate
78+
base: update-lockfiles-${{ matrix.branch }}
79+
labels: |
80+
update-lockfiles
81+
committer: "CoreOS Bot <[email protected]>"
82+
author: "CoreOS Bot <[email protected]>"

0 commit comments

Comments
 (0)