83 lines
2.4 KiB
YAML
83 lines
2.4 KiB
YAML
name: On push to main
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
env:
|
|
PLATFORMS: "linux/amd64,linux/arm64,linux/arm/v7"
|
|
|
|
jobs:
|
|
build_and_push:
|
|
name: Build and push Docker image
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Extract tag string
|
|
id: git
|
|
shell: bash
|
|
run: |
|
|
RELEASE_VERSION="dev-$(date +%s)"
|
|
echo "image_tag=${RELEASE_VERSION}" >> ${GITHUB_OUTPUT}
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v2
|
|
|
|
- name: Install buildx
|
|
uses: docker/setup-buildx-action@v2.7.0
|
|
|
|
- name: Login to docker hub
|
|
uses: docker/login-action@v2.2.0
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
|
|
|
- name: Login to GitHub Container Registry
|
|
uses: docker/login-action@v2.2.0
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.repository_owner }}
|
|
password: ${{ github.token }}
|
|
|
|
- name: Build and push ${{ github.repository }}:${{ steps.git.outputs.image_tag }}
|
|
uses: docker/build-push-action@v4.1.1
|
|
with:
|
|
platforms: ${{ env.PLATFORMS }}
|
|
push: true
|
|
tags: |
|
|
${{ github.repository }}:${{ steps.git.outputs.image_tag }}
|
|
${{ github.repository }}:development
|
|
ghcr.io/${{ github.repository }}:${{ steps.git.outputs.image_tag }}
|
|
ghcr.io/${{ github.repository }}:development
|
|
|
|
clean-ghcr:
|
|
name: Delete old dev container images
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Delete old dev images
|
|
uses: snok/container-retention-policy@v2
|
|
with:
|
|
image-names: endlessh-go
|
|
cut-off: One day ago UTC
|
|
account-type: personal
|
|
token: ${{ secrets.TOKEN_DELETE_GHCR_IMAGES }}
|
|
keep-at-least: 5
|
|
skip-tags: latest, development
|
|
filter-tags: "dev-*"
|
|
dry-run: False
|
|
- name: Delete untagged images
|
|
uses: snok/container-retention-policy@v2
|
|
with:
|
|
image-names: gantry
|
|
cut-off: One hour ago UTC
|
|
account-type: personal
|
|
token: ${{ secrets.TOKEN_DELETE_GHCR_IMAGES }}
|
|
keep-at-least: 0
|
|
untagged-only: True
|
|
skip-tags: latest, development
|
|
dry-run: False
|
|
|