Release release-2024.39 #261
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build | |
on: | |
workflow_dispatch: # allow to run manually | |
push: | |
branches: | |
- '**' | |
tags: | |
- '**' | |
jobs: | |
build-and-push-image: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
attestations: write | |
id-token: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Log in to the container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ghcr.io/onegov/onegov-cloud | |
- name: Build and push docker image | |
id: push | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
- name: Generate artifact attestation | |
uses: actions/attest-build-provenance@v1 | |
with: | |
subject-name: ghcr.io/onegov/onegov-cloud | |
subject-digest: ${{ steps.push.outputs.digest }} | |
push-to-registry: true | |
test-image: | |
runs-on: ubuntu-latest | |
needs: build-and-push-image | |
if: startsWith(github.ref, 'refs/tags/') || contains(github.event.head_commit.message, '[test-container]') | |
strategy: | |
matrix: | |
group: [1, 2, 3, 4, 5, 6] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Log in to the container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ghcr.io/onegov/onegov-cloud | |
- name: Run tests on built image | |
run: | | |
docker pull ghcr.io/onegov/onegov-cloud:${{ steps.meta.outputs.version }} | |
docker run ghcr.io/onegov/onegov-cloud:${{ steps.meta.outputs.version }} test-container "${{matrix.group}}" 6 | |
cleanup-images: | |
runs-on: ubuntu-latest | |
needs: build-and-push-image | |
steps: | |
- name: Delete unttaged images | |
uses: seantis/delete-package-versions@main | |
with: | |
package-name: 'onegov-cloud' | |
package-type: 'container' | |
min-versions-to-keep: 0 | |
delete-only-untagged-versions: 'true' | |
- name: Delete images tagged with commit hash | |
uses: seantis/delete-package-versions@main | |
with: | |
package-name: 'onegov-cloud' | |
package-type: 'container' | |
min-versions-to-keep: 0 | |
ignore-versions: '^(?!sha).*$' | |
ignore-versions-include-tags: true | |
- name: Delete old images | |
uses: seantis/delete-package-versions@main | |
with: | |
package-name: 'onegov-cloud' | |
package-type: 'container' | |
min-versions-to-keep: 20 | |
ignore-versions: '^release-.*$' | |
ignore-versions-include-tags: true |