Skip to content

Commit 18e8e99

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

File tree

1 file changed

+83
-0
lines changed

1 file changed

+83
-0
lines changed
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
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+
if: true == false
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34+
BRANCH: ${{ matrix.branch }}
35+
run: |
36+
TARGET_BRANCH=update-lockfiles-${BRANCH}
37+
echo "The target branch is '$TARGET_BRANCH'."
38+
39+
git remote add upstream https://github.com/coreos/coreos-assembler.git
40+
git fetch upstream
41+
if git ls-remote --heads origin "$TARGET_BRANCH" | grep -q "$TARGET_BRANCH"; then
42+
echo "Branch '$TARGET_BRANCH' exists on origin. Checking it out."
43+
git checkout "$TARGET_BRANCH"
44+
elif git rev-parse --verify --quiet "$TARGET_BRANCH" > /dev/null; then
45+
echo "Branch '$TARGET_BRANCH' exists locally. Checking it out."
46+
git checkout "$TARGET_BRANCH"
47+
else
48+
echo "Branch '$TARGET_BRANCH' does not exist. Creating it from upstream/${BRANCH}."
49+
if git rev-parse --verify --quiet "upstream/${BRANCH}" > /dev/null; then
50+
git checkout -b "$TARGET_BRANCH" upstream/${BRANCH}
51+
echo "Successfully created and checked out branch '$TARGET_BRANCH' from upstream/${BRANCH}."
52+
else
53+
echo "Error: upstream/${BRANCH} does not exist after fetch. Cannot create new branch."
54+
exit 1
55+
fi
56+
fi
57+
git rebase upstream/${BRANCH}
58+
git push --force origin "$TARGET_BRANCH"
59+
60+
- name: Update the lockfiles
61+
working-directory: ci/hermetic
62+
run: |
63+
git checkout update-lockfiles-${{ matrix.branch }}
64+
sudo apt-get update && sudo apt-get install -y python3-dnf
65+
pip3 install requests ruamel.yaml
66+
./update_artifacts_lockfile
67+
bash -x update_rpms_lockfile
68+
69+
- name: Create Pull Request
70+
uses: peter-evans/create-pull-request@v6
71+
with:
72+
token: ${{ secrets.UPDATE_LOCKFILES_PAT }}
73+
commit-message: 'feat(automated): Update the lockfiles'
74+
title: 'Automated: lockfiles updated'
75+
body: |
76+
This PR was automatically generated by the 'Submit PRs to update lockfiles' workflow.
77+
It updates the lockfiles.
78+
branch: update-lockfiles/${{ matrix.branch }}-candidate
79+
base: update-lockfiles-${{ matrix.branch }}
80+
labels: |
81+
update-lockfiles
82+
committer: "CoreOS Bot <coreosbot@fedoraproject.org>"
83+
author: "CoreOS Bot <coreosbot@fedoraproject.org>"

0 commit comments

Comments
 (0)