Build and push timelimit-server-ui image / check (push) Successful in 1s
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
96 lines
3.2 KiB
YAML
96 lines
3.2 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 }}
|
|
tag: ${{ steps.tag.outputs.tag }}
|
|
steps:
|
|
# Get latest timelimit-server tag
|
|
- name: Get timelimit-server tag
|
|
id: tag
|
|
run: |
|
|
LATEST_TAG=$(git ls-remote --tags --refs https://gitea.furb.it/${{ vars.SERVER_PATH }}.git | sort -t '/' -k 3 -V | tail -n 1 | cut -f2 | sed 's/refs\/tags\///')
|
|
echo "tag=$LATEST_TAG" >> $GITEA_OUTPUT
|
|
|
|
# Try to read timelimit-server tag from latest image label
|
|
- name: Check if image with timelimit-server tag exists
|
|
id: exists
|
|
run: |
|
|
TAG="${{ steps.tag.outputs.tag }}"
|
|
|
|
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/$TAG)
|
|
|
|
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.tag }}
|
|
token: ${{ secrets.ACCESS_TOKEN }}
|
|
|
|
# Checkout THIS repository (Dockerfile lives here)
|
|
- name: Checkout current repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
path: docker
|
|
|
|
# Copy custom dockerfile
|
|
- name: Prepare Docker context
|
|
run: |
|
|
cp -f docker/Dockerfile-server Dockerfile
|
|
|
|
# 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 tag
|
|
- name: Build Docker image
|
|
run: |
|
|
docker build \
|
|
-f Dockerfile \
|
|
--label timelimit-server.tag=${{ needs.check.outputs.tag }} \
|
|
-t gitea.furb.it/${{ vars.SERVER_IMAGE }}:${{ needs.check.outputs.tag }} \
|
|
-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.tag }}
|
|
docker push gitea.furb.it/${{ vars.SERVER_IMAGE }}:latest
|
|
|
|
# Create release using gitea-release-action
|
|
- name: Create release
|
|
uses: akkuman/gitea-release-action@v1
|
|
with:
|
|
server: "https://gitea.furb.it"
|
|
token: ${{ secrets.ACCESS_TOKEN }}
|
|
repository: ${{ vars.SERVER_PATH }}
|
|
tag_name: ${{ needs.check.outputs.tag }}
|
|
name: ${{ needs.check.outputs.tag }}
|
|
body: "Docker image: `gitea.furb.it/${{ vars.SERVER_IMAGE }}:${{ needs.check.outputs.tag }}`"
|