-
Notifications
You must be signed in to change notification settings - Fork 2
83 lines (73 loc) · 2.58 KB
/
update_version.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
name: Create PRs for new CoreDNS versions
on:
workflow_dispatch:
schedule:
- cron: "0 10 * * *"
pull_request:
branches:
- main
jobs:
generator:
name: Generate Step for new CoreDNS versions
runs-on: ubuntu-latest
outputs:
tags: ${{ steps.fetch-upstream.outputs.tags }}
steps:
- name: Prepare environment
run: |
export DEBIAN_FRONTEND=noninteractive
sudo apt-get -qq update
sudo apt-get -qq install -y jq
sudo snap install yq
- name: Checkout rock repository
uses: actions/checkout@v4
with:
path: coredns-rock
ref: ${{ github.head_ref || 'main' }}
- name: Checkout coredns repository
uses: actions/checkout@v4
with:
repository: coredns/coredns
path: coredns
fetch-tags: true
fetch-depth: 0
- name: Itemize all releases
id: releases
run: |
rm -rf versions.txt
for rockcraft in $(find coredns-rock -name 'rockcraft.yaml'); do
echo $(yq '.version' $rockcraft) >> versions.txt
done
- name: Craft from Upstream tags
id: fetch-upstream
run: |
current_releases=( $(sort -V versions.txt) )
min_tag="v${current_releases[0]}"
coredns_tags=( $(git -C coredns tag --sort=v:refname | sed -n '/'${min_tag}'/,$p') )
new_tags=()
for coredns_tag in "${coredns_tags[@]}"
do
if [[ ! -e coredns-rock/${coredns_tag:1}/rockcraft.yaml ]]; then
new_tag=${coredns_tag:1}
new_tags+=($new_tag)
tag=${new_tag} envsubst < coredns-rock/template/rockcraft.yaml > coredns-rock/${new_tag}/rockcraft.yaml
fi
done
if [ ${#new_tags[@]} -eq 0 ]; then
tags='[]'
else
tags=$(printf '%s\n' "${new_tags[@]}" | jq -R . | jq --compact-output -s .)
fi
echo $tags
echo "tags=$tags" >> $GITHUB_OUTPUT
- name: Commit and push new rockcraft.yaml
id: commit-rockcraft
if: ${{ steps.fetch-upstream.outputs.tags != '[]' }}
uses: peter-evans/create-pull-request@v7
with:
commit-message: Update CoreDNS versions with ${{ join(fromJSON(steps.fetch-upstream.outputs.tags), ', ') }}
title: "Update CoreDNS versions"
body: Update CoreDNS versions with ${{ join(fromJSON(steps.fetch-upstream.outputs.tags), ', ') }}
branch: autoupdate/sync/coredns
delete-branch: true
base: main