Create PRs for new CoreDNS versions #154
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Create PRs for new CoreDNS versions | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "0 10 * * *" | |
jobs: | |
generator: | |
runs-on: ubuntu-latest | |
outputs: | |
tags: ${{ steps.fetch-upstream.outputs.tags }} | |
steps: | |
- name: Checkout rock repository | |
uses: actions/checkout@v4 | |
with: | |
path: coredns-rock | |
ref: main | |
- name: Checkout coredns repository | |
uses: actions/checkout@v4 | |
with: | |
repository: coredns/coredns | |
path: coredns | |
fetch-tags: true | |
fetch-depth: 0 | |
- name: Get current version from rockcraft.yaml | |
id: currentRockVersion | |
uses: mikefarah/yq@master | |
with: | |
cmd: yq '.version' 'coredns-rock/rockcraft.yaml' | |
- name: Fetch and filter upstream tags | |
id: fetch-upstream | |
run: | | |
export DEBIAN_FRONTEND=noninteractive | |
sudo apt-get -qq update | |
sudo apt-get -qq install -y jq | |
min_tag="v${{ steps.currentRockVersion.outputs.result }}" | |
coredns_tags=( $(git -C coredns tag --sort=-v:refname) ) | |
pr_tags=() | |
for coredns_tag in "${coredns_tags[@]}" | |
do | |
if [ "$min_tag" = "$coredns_tag" ]; then | |
break | |
fi | |
pr_tags+=( "${coredns_tag:1}" ) | |
done | |
if [ ${#pr_tags[@]} -eq 0 ]; then | |
tags='[]' | |
else | |
tags=$(printf '%s\n' "${pr_tags[@]}" | jq -R . | jq --compact-output -s .) | |
fi | |
echo $tags | |
echo "tags=$tags" >> $GITHUB_OUTPUT | |
update: | |
runs-on: ubuntu-latest | |
needs: generator | |
if: ${{ needs.generator.outputs.tags != '[]' }} | |
strategy: | |
matrix: | |
version: ${{ fromJSON(needs.generator.outputs.tags) }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: main | |
- name: Update ROCK's source tag | |
uses: mikefarah/yq@master | |
with: | |
cmd: yq -i '.parts.coredns.source-tag = "v${{ matrix.version }}"' 'rockcraft.yaml' | |
- name: Update ROCK's version | |
uses: mikefarah/yq@master | |
with: | |
cmd: yq -i '.version = "${{ matrix.version }}"' 'rockcraft.yaml' | |
- name: Create pull request | |
uses: peter-evans/create-pull-request@v6 | |
with: | |
commit-message: Update CoreDNS version to ${{ matrix.version }} | |
title: "[${{ matrix.version }}] Update CoreDNS version" | |
body: Update CoreDNS version to ${{ matrix.version }} | |
branch: v${{ matrix.version }} | |
base: main |