aprs.me/.github/workflows/deploy.yml

57 lines
1.4 KiB
YAML

name: Build and Deploy
on:
push:
branches: [main]
# Cancel any in-progress run when a new one is triggered
concurrency:
group: deploy-${{ github.ref }}
cancel-in-progress: true
env:
REGISTRY: git.mcintire.me
IMAGE: git.mcintire.me/graham/aprs.me
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
outputs:
image_tag: ${{ steps.tag.outputs.image_tag }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Compute image tag
id: tag
run: |
TIMESTAMP=$(date +%s)
SHA=${GITHUB_SHA:0:7}
echo "image_tag=main-${TIMESTAMP}-${SHA}" >> "$GITHUB_OUTPUT"
- name: Log in to registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: |
${{ env.IMAGE }}:${{ steps.tag.outputs.image_tag }}
${{ env.IMAGE }}:main
cache-from: type=registry,ref=${{ env.IMAGE }}:main
cache-to: type=inline