Skip to content

Update Dependencies #45

Update Dependencies

Update Dependencies #45

Workflow file for this run

name: Update Dependencies
on:
schedule:
# Daily at midnight UTC
- cron: 0 0 * * *
workflow_dispatch:
permissions:
actions: write
contents: write
packages: write
id-token: write
jobs:
# Ensure this only runs on main
guard:
runs-on: ubuntu-24.04
if: github.ref_name == 'main'
steps:
- run: true
# Compare pinned version in Dockerfile against latest Docker Hub tag
check:
needs: guard
runs-on: ubuntu-24.04
outputs:
latest: ${{ steps.latest.outputs.version }}
needs_update: ${{ steps.compare.outputs.needs_update }}
steps:
- uses: actions/checkout@v6
- name: Current version
id: current
run: |
version=$(sed -n 's/^ARG ALPINE_VERSION=//p' src/Dockerfile)
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Latest version
id: latest
run: |
version=$(curl -s "https://hub.docker.com/v2/repositories/library/alpine/tags?page_size=100&ordering=last_updated" | jq -r '[.results[].name | select(test("^[0-9]+\\.[0-9]+\\.[0-9]+$"))][0]')
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Compare
id: compare
run: |
if [[ "${{ steps.latest.outputs.version }}" != "${{ steps.current.outputs.version }}" ]]; then
echo "needs_update=true" >> "$GITHUB_OUTPUT"
fi
- name: Summary
run: |
cat >> "$GITHUB_STEP_SUMMARY" <<EOF
```yaml
latest: ${{ steps.latest.outputs.version }}
current: ${{ steps.current.outputs.version }}
needs_update: ${{ steps.compare.outputs.needs_update }}
```
EOF
# Update the pinned version, commit, and push
update:
needs: check
if: needs.check.outputs.needs_update == 'true'
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
- name: Replace
run: sed -i "s/^ARG ALPINE_VERSION=.*/ARG ALPINE_VERSION=${{ needs.check.outputs.latest }}/" src/Dockerfile
- name: Configure
run: ${{ secrets.GIT_CONFIG }}
- name: List
run: git config --list
- name: Stage
run: git add src/Dockerfile
- name: Diff
run: git diff --staged
- name: Commit
run: |
git commit -m 'feat: update alpine to `${{ needs.check.outputs.latest }}`'
- name: Push
run: git push
# Build and publish the updated image
ci:
needs: update
uses: ./.github/workflows/ci.yml
with:
ref: main
secrets: inherit