Skip to content

Check upstream versions #948

Check upstream versions

Check upstream versions #948

---
name: Check upstream versions
on:
workflow_dispatch:
schedule:
- cron: "0 12 * * *"
jobs:
version_in_container:
name: Check version in 'latest' image
runs-on: ubuntu-latest
outputs:
currver: ${{ steps.current-version.outputs.currver }}
steps:
- name: Get version from ghcr.io/${{ github.repository }}:latest
id: current-version
run: |
set -x
echo "currver=$(docker run --rm --entrypoint cat ghcr.io/${{ github.repository }}:latest /CONTAINER_VERSION)" >> $GITHUB_OUTPUT
latest_version:
name: Check latest versions
runs-on: ubuntu-latest
outputs:
latestver: ${{ steps.latest-version.outputs.latestver }}
steps:
- name: Build image
uses: docker/[email protected]
with:
push: false
load: true
tags: testing:latest
- name: Get version from newly built image
id: latest-version
run: |
set -x
echo "latestver=$(docker run --rm --entrypoint cat testing:latest /CONTAINER_VERSION)" >> $GITHUB_OUTPUT
display_versions:
name: Display versions
needs: [version_in_container, latest_version]
runs-on: ubuntu-latest
steps:
- name: Display versions
run: |
echo "versions in ghcr.io/${{ github.repository }}:latest = ${{ needs.version_in_container.outputs.currver }}"
echo "versions in apt repository = ${{ needs.latest_version.outputs.latestver }}"
echo "will a deployment be triggered = ${{ needs.version_in_container.outputs.currver != needs.latest_version.outputs.latestver }}"
trigger_deploy:
name: Trigger deployment on new versions
needs: [version_in_container, latest_version]
if: ${{ needs.version_in_container.outputs.currver != needs.latest_version.outputs.latestver }}
runs-on: ubuntu-latest
env:
WORKFLOW_AUTH_TOKEN: ${{ secrets.GH_PAT_MIKENYE }}
WORKFLOW_REPO: ${{ github.repository }}
WORKFLOW_FILE: deploy.yml
WORKFLOW_REASON: "triggered via check_versions.yml in ${{ github.repository }}"
steps:
- name: Trigger ${{ env.WORKFLOW_FILE }} in ${{ env.WORKFLOW_REPO }}
run: |
echo "$WORKFLOW_AUTH_TOKEN" | gh auth login --with-token
gh workflow run --ref main --repo "$WORKFLOW_REPO" "$WORKFLOW_FILE" -f reason="$WORKFLOW_REASON"