-
Notifications
You must be signed in to change notification settings - Fork 15
158 lines (139 loc) · 6.44 KB
/
Copy pathupdate-valkey-container.yml
File metadata and controls
158 lines (139 loc) · 6.44 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
name: Update Valkey Container
on:
workflow_call:
inputs:
version:
type: string
description: "Valkey version that was released"
required: true
outputs:
bashbrew_output:
description: "Bashbrew output in JSON format"
value: ${{ jobs.build-new-docker.outputs.bashbrew_json }}
jobs:
build-new-docker:
runs-on: ubuntu-latest
outputs:
bashbrew_json: ${{ steps.generate-bashbrew.outputs.bashbrew_content }}
steps:
- name: Validate inputs
run: |
if [[ ! "${{ inputs.version }}" =~ ^([0-9]+\.[0-9]+\.[0-9]+(-rc[0-9]+)?|unstable)$ ]]; then
echo "Invalid version format. Expected format: x.y.z or 'unstable'"
exit 1
fi
- name: Generate token
id: generate-token
if: github.repository_owner == 'valkey-io'
uses: actions/create-github-app-token@d72941d797fd3113feb6b93fd0dec494b13a2547 # v1.12.0
with:
app-id: ${{ secrets.VALKEYRIE_BOT_APP_ID }}
private-key: ${{ secrets.VALKEYRIE_BOT_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
repositories: valkey-container,valkey-release-automation
- name: Set up bashbrew
uses: docker-library/bashbrew@v0.1.13
- name: Check if bashbrew is installed
run: |
bashbrew --version
- name: Checkout valkey-release-automation
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
repository: ${{ github.repository_owner }}/valkey-release-automation
path: valkey-release-automation
- name: Checkout valkey-container
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
repository: ${{ github.repository_owner }}/valkey-container
path: valkey-container
token: ${{ github.repository_owner == 'valkey-io' && steps.generate-token.outputs.token || secrets.AUTOMATION_PAT }}
- name: Checkout valkey-release-automation
uses: actions/checkout@v4
with:
repository: ${{ github.repository_owner }}/valkey-release-automation
path: valkey-release-automation
token: ${{ github.repository_owner == 'valkey-io' && steps.generate-token.outputs.token || secrets.AUTOMATION_PAT }}
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Strip patch version
id: strip_version
run: |
if [[ "${{ inputs.version }}" == "unstable" ]]; then
echo "Version is unstable"
echo "stripped_version=unstable" >> $GITHUB_OUTPUT
elif [[ "${{ inputs.version }}" =~ ^([0-9]+\.[0-9]+)\.[0-9]+(-rc[0-9]+)?$ ]]; then
stripped_version="${BASH_REMATCH[1]}"
echo "Stripped version: $stripped_version"
echo "stripped_version=$stripped_version" >> $GITHUB_OUTPUT
else
echo "Version doesn't match expected format"
exit 1
fi
shell: bash
- name: Update new version
id: version-update
run: |
cd valkey-container
# Download the scripts for bashbrew in local
jqt='.jq-template.awk'
wget -qO "$jqt" 'https://github.com/docker-library/bashbrew/raw/9f6a35772ac863a0241f147c820354e4008edf38/scripts/jq-template.awk'
jqf='.template-helper-functions.jq'
wget -qO "$jqf" 'https://github.com/docker-library/bashbrew/raw/08c926140ad0af22de58c2a2656afda58082ba3e/scripts/template-helper-functions.jq'
# Run update script
./update.sh ${{ steps.strip_version.outputs.stripped_version }}
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add .
# Only commit if there are changes
if ! git diff --cached --quiet; then
git commit -m "Update versions.json and Dockerfiles for version ${{ inputs.version }}" -s
echo "has_changes=true" >> $GITHUB_OUTPUT
else
echo "No changes to commit for version update - PR will not be created."
echo "has_changes=false" >> $GITHUB_OUTPUT
fi
- name: Update container aliases
id: alias-update
run: |
cd valkey-container
python ../valkey-release-automation/scripts/automate_alias_update.py \
generate-stackbrew-library.sh \
${{ inputs.version }}
git add generate-stackbrew-library.sh
# Only commit if there are changes
if ! git diff --cached --quiet; then
git commit -m "Update container aliases for version ${{ inputs.version }}" -s
echo "has_changes=true" >> $GITHUB_OUTPUT
else
echo "No changes to commit for aliases - PR will not be created."
echo "has_changes=false" >> $GITHUB_OUTPUT
fi
- name: Generate bashbrew output
id: generate-bashbrew
run: |
cd valkey-container
BASHBREW_SCRIPTS=/home/runner/work/_actions/docker-library/bashbrew/v0.1.13/scripts
"$BASHBREW_SCRIPTS/github-actions/generate.sh" > bashbrew_output.json
echo "bashbrew_content=$(cat bashbrew_output.json)" >> $GITHUB_OUTPUT
rm bashbrew_output.json
- name: Create Pull Request
if: |
steps.version-update.outputs.has_changes == 'true' ||
steps.alias-update.outputs.has_changes == 'true'
id: create-pr
uses: peter-evans/create-pull-request@v7
with:
token: ${{ github.repository_owner == 'valkey-io' && steps.generate-token.outputs.token || secrets.AUTOMATION_PAT }}
path: valkey-container
branch: update-${{ inputs.version }}
commit-message: "Preparing changes for version ${{ inputs.version }}"
committer: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
delete-branch: true
signoff: true
author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
title: "Update to version ${{ inputs.version }}"
body: |
This pull request updates the repository to version `${{ inputs.version }}`.
This pull request is created automatically by the [Valkey-Release-Automation](https://github.com/valkey-io/valkey-release-automation)