forked from opendatahub-io/notebooks
-
Notifications
You must be signed in to change notification settings - Fork 1
116 lines (104 loc) · 4.07 KB
/
runtimes-digest-updater-upstream.yaml
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
---
# The aim of this GitHub workflow is to update the runtimes ImageStreams
name: Update runtime ImageStreams SHA digests
on: # yamllint disable-line rule:truthy
workflow_dispatch:
inputs:
branch:
required: true
description: "Which branch do you want to update?"
tag_version:
required: true
description: "Provide tag version: main or YYYYx"
user-hash:
required: false
description: "Optional: Specify a Git hash (it should exist in the provided branch's history)"
env:
TMP_BRANCH: tmp-branch-${{ github.run_id }}
BRANCH_NAME: ${{ github.event.inputs.branch || 'main' }}
TAG_VERSION: ${{ github.event.inputs.tag_version || 'main' }}
USER_HASH: ${{ github.event.inputs.user-hash }}
jobs:
initialize:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Install Skopeo CLI
shell: bash
run: |
sudo apt-get -y update
sudo apt-get -y install skopeo yq jq
- name: Checkout branch
uses: actions/checkout@v4
with:
ref: ${{ env.BRANCH_NAME }}
- name: Create a new branch
run: |
echo ${{ env.TMP_BRANCH }}
git checkout -b ${{ env.TMP_BRANCH }}
git push --set-upstream origin ${{ env.TMP_BRANCH }}
update-runtimes:
needs: [initialize]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Configure Git
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "GitHub Actions"
- name: Checkout release branch
uses: actions/checkout@v4
with:
ref: ${{ env.TMP_BRANCH }}
fetch-depth: 0
- name: Invoke script to handle the update
shell: bash
run: |
chmod +x "${GITHUB_WORKSPACE}/ci/runtimes-digest-updater.sh"
bash ${GITHUB_WORKSPACE}/ci/runtimes-digest-updater.sh ${{ env.TAG_VERSION }} ${{ env.USER_HASH }}
- name: Commit the changes
run: |
if [[ $(git status --porcelain | wc -l) -gt 0 ]]; then
git fetch origin "${{ env.TMP_BRANCH }}" && \
git pull origin "${{ env.TMP_BRANCH }}" && \
git add "manifests/base/runtime-*" && \
git commit -m "Update file via ${{ env.TMP_BRANCH }} GitHub action" && \
git push origin "${{ env.TMP_BRANCH }}"
else
echo "There were no changes detected in the images for the ${{ env.BRANCH_NAME }}"
fi
open-pull-request:
needs: [update-runtimes]
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Read skipped files (if any)
id: skipped-files
run: |
if [[ -f "${GITHUB_WORKSPACE}/skipped_files.txt" && -s "${GITHUB_WORKSPACE}/skipped_files.txt" ]]; then
echo "### Skipped Files" >> pr_body.txt
echo "Some files were skipped during the update process due to missing tags in the registry:" >> pr_body.txt
cat ${GITHUB_WORKSPACE}/skipped_files.txt >> pr_body.txt
echo "" >> pr_body.txt
fi
- name: Generate PR Body
run: |
echo ":rocket: This is an automated Pull Request." > full_pr_body.txt
echo "Created by \`/.github/workflows/runtimes-digest-updater-upstream.yaml\`" >> full_pr_body.txt
echo "" >> full_pr_body.txt
if [[ -f "pr_body.txt" ]]; then cat pr_body.txt >> full_pr_body.txt; fi
echo ":exclamation: **IMPORTANT NOTE**: Remember to delete the \`${{ env.TMP_BRANCH }}\` branch after merging the changes" >> full_pr_body.txt
- name: pull-request
uses: repo-sync/pull-request@v2
with:
source_branch: ${{ env.TMP_BRANCH }}
destination_branch: ${{ env.BRANCH_NAME }}
github_token: ${{ secrets.GITHUB_TOKEN }}
pr_label: "automated pr"
pr_title: "[Digest Updater Action] Update Runtime ImageStreams"
pr_body_path: full_pr_body.txt