Skip to content

update-version

update-version #1425

Workflow file for this run

name: update-version
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *' # Midnight - every night
jobs:
get_version:
runs-on: ubuntu-latest
name: Get next GITHUB_CLI_VERSION
# https://stackoverflow.com/a/61236803
outputs:
gh_version: ${{ steps.gh_version.outputs.gh_version }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: Get next gh version
id: gh_version
run: |
next_version="$(bash get-version.sh ${{ secrets.GITHUB_TOKEN }})"
echo "$next_version"
echo "gh_version=${next_version}" >> $GITHUB_OUTPUT
update:
runs-on: ubuntu-latest
name: Update GITHUB_CLI_VERSION
needs: get_version
if: ${{ needs.get_version.outputs.gh_version != '' }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: Write gh version to env
run: |
echo "gh_version=${{needs.get_version.outputs.gh_version}}" >> $GITHUB_ENV
- name: Update GITHUB_CLI_VERSION
run: |
echo "${{ env.gh_version }}" | grep -Pq "^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$"
find . -name Dockerfile -print0 | xargs -0 sed -i -E "s/^(ENV GITHUB_CLI_VERSION\s*).*$/\1${{ env.gh_version }}/g"
- name: Login to GitHub Container Registry
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Commit changes
uses: stefanzweifel/[email protected]
id: "commit"
with:
commit_message: "Update GITHUB_CLI_VERSION to ${{ env.gh_version }}"
commit_user_name: actions-user
commit_user_email: [email protected]
commit_author: GitHub Actions <[email protected]>
- name: Push Docker Image
if: steps.commit.outputs.changes_detected == 'true'
uses: docker/[email protected]
with:
push: true
context: .
file: ./debian/Dockerfile
tags: |
ghcr.io/${{ github.repository }}:${{ env.gh_version }}
ghcr.io/${{ github.repository }}:latest