Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/cleanup-pr-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
name: Delete closed PR container image tag

"on":
pull_request:
types:
- closed

jobs:
cleanup-pr-tag:
runs-on: ubuntu-latest
steps:
- name: Set image version for PR to branch name
run: echo "VERSION=${GITHUB_HEAD_REF//\//-}" >> ${GITHUB_ENV}

- name: Delete PR container image tag
uses: dataaxiom/ghcr-cleanup-action@v1
with:
tags: ${{ env.VERSION }}
package: ${{ github.event.repository.name }}
token: ${{ secrets.GITHUB_TOKEN }}
73 changes: 59 additions & 14 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,63 @@ on:
- master
tags:
- v*
pull_request: {}
Comment thread
HappyTetrahedron marked this conversation as resolved.

jobs:
build:
runs-on: ubuntu-latest
env:
IMAGE: docker.io/${{ github.repository }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: "0"
fetch-depth: 0 # NOTE(aa): Required in order to have tag information available
- name: Get version information
id: get-version-info
run: |
GITVERSION="$(git describe --tags --always --match=v* --dirty=+dirty || (echo "command failed $?"; exit 1))"
PYVERSION="$(git describe --tags --always --match=v* | cut -d- -f1,2 || (echo "command failed $?"; exit 1))"
echo "git version: $GITVERSION, pyversion: $PYVERSION"
echo "gitversion=${GITVERSION}" >> ${GITHUB_OUTPUT}
echo "pyversion=${PYVERSION}" >> ${GITHUB_OUTPUT}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Set image version latest
if: github.ref == 'refs/heads/master'
run: echo "VERSION=latest" >> ${GITHUB_ENV}
- name: Set image version for PRs to branch name
if: github.event_name == 'pull_request'
run: echo "VERSION=${GITHUB_HEAD_REF//\//-}" >> ${GITHUB_ENV}
- name: Set image version from tag
if: startsWith(github.ref, 'refs/tags/v')
run: echo "VERSION=$(echo ${GITHUB_REF#refs/tags/})" >> ${GITHUB_ENV}
- name: Build Image
run: make docker
env:
IMAGE_NAME: "${IMAGE}:${VERSION}"
- name: Push Image
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: |
docker login docker.io --username "${DOCKER_USERNAME}" --password "${DOCKER_PASSWORD}"
docker push "${IMAGE}:${VERSION}"
- name: Login to docker.io
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: docker.io
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to ghcr.io
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
push: true
tags: |
ghcr.io/${{ github.repository }}:${{ env.VERSION }}
${{ github.event_name != 'pull_request' && format('{{docker.io/{0}:{1}}}', github.repository, env.VERSION) || '' }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
GITVERSION=${{ steps.get-version-info.outputs.gitversion }}
PYVERSION=${{ steps.get-version-info.outputs.pyversion }}
- name: Build changelog from PRs with labels
if: startsWith(github.ref, 'refs/tags/v')
id: build_changelog
Expand Down Expand Up @@ -74,3 +104,18 @@ jobs:
# Ensure target branch for release is "master"
commit: master
token: ${{ secrets.GITHUB_TOKEN }}
- name: Delete untagged container images
# We always delete all untagged container images after building an
# image. This way, there should never be stale untagged images laying
# around in the registry. In combination with the workflow that
# deletes PR tags after the PR is closed we should be able to keep the
# container image registry size in check.
uses: dataaxiom/ghcr-cleanup-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
package: ${{ github.event.repository.name }}
validate: true
- name: Run image
if: github.event_name == 'pull_request'
run: |
docker run ghcr.io/projectsyn/commodore:"${VERSION}" version
14 changes: 0 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,17 +150,3 @@ jobs:
- uses: actions/checkout@v6
- name: Check Docs
run: make docs-vale
build:
needs:
- lints
- tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: "0"
- name: Build image
run: make docker
- name: Run image
run: |
docker run docker.io/projectsyn/commodore:test version
Comment thread
HappyTetrahedron marked this conversation as resolved.
Loading