Update Snap Revisions #965
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: Update Snap Revisions | |
on: | |
schedule: | |
- cron: "0 */5 * * *" # every 5 hours | |
jobs: | |
stable-branches: | |
runs-on: ubuntu-latest | |
outputs: | |
branches: ${{ steps.release-branches.outputs.data }} | |
steps: | |
- uses: octokit/[email protected] | |
id: list-branches | |
with: | |
route: GET /repos/${{ github.repository }}/branches | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- id: release-branches | |
run: |- | |
DATA='${{ steps.list-branches.outputs.data }}' | |
NAMES=$(jq -r '.[] | .name' <<< $DATA) | |
RELEASES=() | |
for BRANCH in ${NAMES}; do | |
if [[ "${BRANCH}" =~ ^release-[0-9]+\.[0-9]+$ ]]; then | |
RELEASES+=($BRANCH) | |
fi | |
done | |
echo data=$(printf '%s\n' "${RELEASES[@]}" | jq -R . | jq -s .) >> ${GITHUB_OUTPUT} | |
update-branches: | |
runs-on: ubuntu-latest | |
needs: [stable-branches] | |
strategy: | |
matrix: | |
branch: ${{ fromJSON(needs.stable-branches.outputs.branches) }} | |
arch: ["amd64", "arm64"] | |
steps: | |
- name: Prepare Track | |
run: |- | |
BRANCH="${{matrix.branch}}" | |
echo "TRACK=${BRANCH:8}" | tee -a "$GITHUB_ENV" | |
- name: Checkout ${{ matrix.branch }} | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ matrix.branch }} | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12' | |
- name: Update Revision | |
id: update-revision | |
run: | | |
pip install pyyaml | |
python3 .github/workflows/update-snap-revision.py ${{ matrix.arch }} | |
- name: Create pull request | |
uses: peter-evans/create-pull-request@v7 | |
if: ${{ steps.update-revision.outputs.result != '' }} | |
with: | |
commit-message: '[Release ${{ env.TRACK }}] Update K8s ${{ env.TRACK }} revision to ${{ steps.update-revision.outputs.result }} on ${{ matrix.arch }}' | |
title: "[Release ${{ env.TRACK }}] Update K8s ${{ env.TRACK }} revision on ${{ matrix.arch }}" | |
body: |- | |
Updates K8s version for ${{ env.TRACK }} | |
* revision=${{ steps.update-revision.outputs.result }} | |
* arch = ${{ matrix.arch }} | |
branch: revision-update-job/${{ env.TRACK }}/${{matrix.arch}}/${{ steps.update-revision.outputs.result }} | |
base: ${{ matrix.branch }} | |
add-paths: | | |
charms/worker/k8s/templates/*.yaml | |