Build and push timelimit-server-ui image / check (push) Successful in 21s
Build and push timelimit-server-ui image / build (push) Has been skipped
Build and push timelimit-server image / check (push) Successful in 1s
Build and push timelimit-server image / build (push) Has been skipped
75 lines
2.5 KiB
YAML
75 lines
2.5 KiB
YAML
name: Build and push timelimit-server image
|
|
|
|
on:
|
|
schedule:
|
|
- cron: "30 5 */3 * *" # every 72 hours
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
check:
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
exists: ${{ steps.exists.outputs.exists }}
|
|
sha: ${{ steps.sha.outputs.sha }}
|
|
steps:
|
|
# Get latest timelimit-server commit SHA
|
|
- name: Get timelimit-server commit SHA
|
|
id: sha
|
|
run: |
|
|
SHA=$(git ls-remote https://gitea.furb.it/${{ vars.SERVER_PATH }}.git refs/heads/${{ vars.SERVER_BRANCH }} | cut -f1)
|
|
echo "sha=$SHA" >> $GITEA_OUTPUT
|
|
|
|
# Try to read timelimit-server SHA from latest image label
|
|
- name: Check if image with timelimit-server SHA exists
|
|
id: exists
|
|
run: |
|
|
SHA="${{ steps.sha.outputs.sha }}"
|
|
|
|
STATUS=$(curl -s -o /dev/null -w "%{http_code}" \
|
|
-u "${{ secrets.USERNAME }}:${{ secrets.ACCESS_TOKEN }}" \
|
|
-H "Accept: application/vnd.docker.distribution.manifest.v2+json" \
|
|
https://gitea.furb.it/v2/${{ vars.SERVER_IMAGE }}/manifests/$SHA)
|
|
|
|
if [ "$STATUS" = "200" ]; then
|
|
echo "exists=true" >> $GITEA_OUTPUT
|
|
else
|
|
echo "exists=false" >> $GITEA_OUTPUT
|
|
fi
|
|
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
needs: check
|
|
if: needs.check.outputs.exists == 'false'
|
|
steps:
|
|
|
|
# Checkout timelimit-server repository for build
|
|
- name: Checkout timelimit-server repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
repository: ${{ vars.SERVER_PATH }}.git
|
|
ref: ${{ needs.check.outputs.sha }}
|
|
token: ${{ secrets.ACCESS_TOKEN }}
|
|
|
|
# Login to registry (needed to inspect latest image)
|
|
- name: Docker login
|
|
run: |
|
|
echo "${{ secrets.ACCESS_TOKEN }}" | docker login gitea.furb.it \
|
|
-u "${{ secrets.USERNAME }}" \
|
|
--password-stdin
|
|
|
|
# Build image with commit-SHA tag and label
|
|
- name: Build Docker image
|
|
run: |
|
|
docker build \
|
|
-f Dockerfile \
|
|
--label timelimit-server.sha=${{ needs.check.outputs.sha }} \
|
|
-t gitea.furb.it/${{ vars.SERVER_IMAGE }}:${{ needs.check.outputs.sha }} \
|
|
-t gitea.furb.it/${{ vars.SERVER_IMAGE }}:latest \
|
|
.
|
|
|
|
# Push images
|
|
- name: Push Docker images
|
|
run: |
|
|
docker push gitea.furb.it/${{ vars.SERVER_IMAGE }}:${{ needs.check.outputs.sha }}
|
|
docker push gitea.furb.it/${{ vars.SERVER_IMAGE }}:latest
|