generated from nathanwoodburn/python-webserver-template
54 lines
1.7 KiB
YAML
54 lines
1.7 KiB
YAML
name: Build Docker fast
|
|
run-name: Build Docker Images fast
|
|
on:
|
|
push:
|
|
|
|
jobs:
|
|
BuildImage:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v2
|
|
|
|
- name: Login to Docker Registry
|
|
uses: docker/login-action@v2
|
|
with:
|
|
registry: git.woodburn.au
|
|
username: nathanwoodburn
|
|
password: ${{ secrets.DOCKERGIT_TOKEN }}
|
|
|
|
- name: Extract metadata
|
|
id: meta
|
|
run: |
|
|
echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
|
|
tag=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}
|
|
tag=${tag//\//-}
|
|
echo "tag=$tag" >> $GITHUB_OUTPUT
|
|
tag_num=${GITHUB_RUN_NUMBER}
|
|
echo "tag_num=$tag_num" >> $GITHUB_OUTPUT
|
|
|
|
if [[ "$tag" == "main" ]]; then
|
|
echo "final_tag=latest" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "final_tag=${tag}-${tag_num}" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
repo=$GITHUB_REPOSITORY
|
|
repo=${repo#*/}
|
|
repo=$(echo $repo | tr '[:upper:]' '[:lower:]')
|
|
echo "repo=$repo" >> $GITHUB_OUTPUT
|
|
|
|
- name: Build and push
|
|
uses: docker/build-push-action@v4
|
|
with:
|
|
context: .
|
|
push: true
|
|
tags: |
|
|
git.woodburn.au/nathanwoodburn/${{ steps.meta.outputs.repo }}:${{ steps.meta.outputs.final_tag }}
|
|
git.woodburn.au/nathanwoodburn/${{ steps.meta.outputs.repo }}:${{ steps.meta.outputs.tag_num }}
|
|
git.woodburn.au/nathanwoodburn/${{ steps.meta.outputs.repo }}:${{ steps.meta.outputs.tag }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max |