56 lines
1.8 KiB
YAML
56 lines
1.8 KiB
YAML
name: Alpine Package Auto-Rebuild
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
schedule:
|
|
- cron: '0 1 * * *' # Daily at 1:00 AM UTC
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: docker:rc-cli
|
|
|
|
steps:
|
|
- name: Install dependencies for other steps
|
|
shell: sh
|
|
run: |
|
|
apk add --no-cache git nodejs npm bash
|
|
|
|
- name: Checkout repo
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Check for latest package version
|
|
id: check
|
|
run: |
|
|
PACKAGE="curl"
|
|
LATEST=$(apk policy $PACKAGE | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+[_a-zA-Z0-9.-]*' | head -n1 || echo "unknown")
|
|
echo "latest_version=$LATEST" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Compare with last known version
|
|
id: compare
|
|
run: |
|
|
FILE=".last_version"
|
|
[ -f "$FILE" ] && LAST=$(cat "$FILE") || LAST="none"
|
|
echo "Last known version: $LAST"
|
|
if [ "$LAST" != "${{ steps.check.outputs.latest_version }}" ]; then
|
|
echo "update=true" >> "$GITHUB_OUTPUT"
|
|
else
|
|
echo "update=false" >> "$GITHUB_OUTPUT"
|
|
fi
|
|
|
|
- name: Build and push Docker image
|
|
if: steps.compare.outputs.update == 'true'
|
|
run: |
|
|
docker build -t melody/docker-test:latest .
|
|
echo "${{ secrets.DOCKER_PASSWORD }}" | docker login git.shork.ch -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
|
|
docker push git.shork.ch/melody/docker-test:latest
|
|
echo "${{ steps.check.outputs.latest_version }}" > .last_version
|
|
|
|
- name: Commit updated version file
|
|
if: steps.compare.outputs.update == 'true'
|
|
run: |
|
|
git config user.name "forgejo-runner"
|
|
git config user.email "runner@forgejo.local"
|
|
git add .last_version
|
|
git commit -m "Update tracked version to ${{ steps.check.outputs.latest_version }}"
|
|
git push
|
|
|