From ecce9c388ce0d24daed010abe13634ec07108082 Mon Sep 17 00:00:00 2001 From: Martin Buchleitner Date: Wed, 8 May 2024 12:02:00 +0200 Subject: [PATCH] fix: Change workflow (#7) * fix: Change workflow Signed-off-by: Martin Buchleitner --------- Signed-off-by: Martin Buchleitner --- .github/workflows/docker.yml | 148 ++++------------------------------- 1 file changed, 14 insertions(+), 134 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index e3f0b0e..273eec0 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,143 +1,23 @@ name: Infralovers Container Build -# ref: github.com/infralovers/github/workflow-templates/container.yml - on: push: - branches: [ 'main' ] + branches: [ main ] + pull_request: - branches: [ 'main' ] - tags: [ "v*.*.*" ] + branches: [ main ] jobs: - prebuild: - runs-on: ubuntu-latest - outputs: - version: ${{ steps.semrel.outputs.version }} - steps: - - uses: actions/checkout@v3 - - - name: Check pre-commit presence - id: precommit_exists - uses: andstor/file-existence-action@v1 - with: - files: ".pre-commit-config.yaml" - - - uses: actions/setup-python@v3 - if: steps.precommit_exists.outputs.files_exists == 'true' - - - uses: pre-commit/action@v3.0.0 - if: steps.precommit_exists.outputs.files_exists == 'true' - - - uses: go-semantic-release/action@v1 - if: github.event_name != 'pull_request' - id: semrel - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - prepend: true - dry: true build: - runs-on: ubuntu-latest - needs: [ prebuild ] - steps: - - uses: actions/checkout@v2 - - - name: Prepare tagging - id: prep - run: | - IMAGE_NAME=$(basename ${{ github.repository }}) - IMAGE_REPO=${{ github.repository_owner }} - if [[ -n "${{ secrets.IMAGE_NAME }}" ]]; then - IMAGE_NAME="${{ secrets.IMAGE_NAME }}" - fi - if [[ -n "${{ secrets.IMAGE_REPO }}" ]]; then - IMAGE_REPO="${{ secrets.IMAGE_REPO }}" - fi - QUAY_IMAGE="quay.io/$IMAGE_REPO/$IMAGE_NAME" - GHCR_IMAGE="ghcr.io/${{ github.repository }}" - - TAGS="${QUAY_IMAGE},${GHCR_IMAGE}" - echo "settings tag ${TAGS}" - echo "tags=${TAGS}" >> $GITHUB_OUTPUT - - - name: Docker meta - id: meta - uses: docker/metadata-action@v4 - with: - images: ${{ steps.prep.outputs.tags }} - tags: | - type=raw,value=${{ needs.prebuild.outputs.version }} - type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }} - type=ref,event=pr - type=ref,event=branch,enable=${{ github.ref != format('refs/heads/{0}', 'main') }} - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=sha - - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v2 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - with: - platforms: 'arm64,arm,amd64' - - - name: Cache Docker layers - uses: actions/cache@v2 - with: - path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-buildx- - - - name: Login to Quay - if: github.event_name != 'pull_request' - uses: docker/login-action@v1 - with: - registry: quay.io - username: ${{ secrets.QUAY_USER }} - password: ${{ secrets.QUAY_TOKEN }} - - - name: Login to GitHub Container Registry - if: github.event_name != 'pull_request' - uses: docker/login-action@v1 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.BOT_ACCESS_TOKEN }} - - - name: Build and push - id: docker_build - uses: docker/build-push-action@v4 - with: - builder: ${{ steps.buildx.outputs.name }} - context: . - push: ${{ github.event_name != 'pull_request' && needs.prebuild.outputs.version != '' }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - platforms: 'arm64,amd64' - - release: - needs: [ prebuild, build ] - if: github.event_name != 'pull_request' - runs-on: ubuntu-latest - steps: - - - uses: actions/checkout@v2 - - - uses: go-semantic-release/action@v1 - if: needs.prebuild.outputs.version != '' - id: generate_changelog - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - prepend: true - changelog-file: CHANGELOG.md - - - name: Update changelog - uses: stefanzweifel/git-auto-commit-action@v4 - if: steps.generate_changelog.outputs.version != '' - with: - commit_message: 'commit changes from go-semantic-release' - file_pattern: CHANGELOG.md + uses: infralovers/.github/.github/workflows/container.yml@main + secrets: + QUAY_USER: "${{ fromJSON(secrets.VAULT_KV_1D187965_OP_QUAY_ROBOT_ACCOUNT).username }}" + QUAY_TOKEN: "${{ fromJSON(secrets.VAULT_KV_1D187965_OP_QUAY_ROBOT_ACCOUNT).password }}" + BOT_ACCESS_TOKEN: "${{ fromJSON(secrets.VAULT_KV_1D187965_OP_GITHUB_INFRALOVERS).PAT }}" + MONDOO_SERVICE_ACCOUNT: "${{ fromJson(secrets.VAULT_KV_1D187965_OP_MONDOO_PACKER_AGENT).password }}" + with: + dockerfile: Dockerfile + score: 0 + platforms: "linux/amd64, linux/arm64" + release: true