From 2393867e71daa52e19939e11aeb051e4102eb383 Mon Sep 17 00:00:00 2001 From: yoon Date: Fri, 2 Aug 2024 00:49:15 +0900 Subject: [PATCH] Update atlantis-image.yml --- .github/workflows/atlantis-image.yml | 85 ++++------------------------ 1 file changed, 10 insertions(+), 75 deletions(-) diff --git a/.github/workflows/atlantis-image.yml b/.github/workflows/atlantis-image.yml index 4e90f65f15..3b3d5047b2 100644 --- a/.github/workflows/atlantis-image.yml +++ b/.github/workflows/atlantis-image.yml @@ -48,7 +48,7 @@ jobs: build: needs: [changes] - # if: needs.changes.outputs.should-run-build == 'true' + if: needs.changes.outputs.should-run-build == 'true' name: Build Image strategy: matrix: @@ -81,28 +81,13 @@ jobs: - name: Docker meta id: meta uses: docker/metadata-action@v5 - env: - SUFFIX: ${{ format('-{0}', matrix.image_type) }} with: - images: | - ${{ env.DOCKER_REPO }} + images: ${{ env.DOCKER_REPO }} labels: | org.opencontainers.image.authors="@runatlantis Github Org" org.opencontainers.image.licenses=Apache-2.0 - tags: | - type=semver,pattern={{version}},prefix=v,suffix=${{ env.SUFFIX }} - type=semver,pattern={{version}},prefix=v,enable=${{ matrix.image_type == 'alpine' }} - type=semver,pattern={{major}}.{{minor}},prefix=v,suffix=${{ env.SUFFIX }} - type=raw,event=push,value=dev,enable={{is_default_branch}},suffix=${{ env.SUFFIX }} - type=raw,event=push,value=dev,enable={{is_default_branch}},suffix=${{ env.SUFFIX }}-{{ sha }} - type=raw,event=push,value=dev,enable=${{ github.ref == format('refs/heads/{0}', 'main') && matrix.image_type == 'alpine' }},suffix= - type=raw,event=tag,value=prerelease-latest,enable=${{ startsWith(github.ref, 'refs/tags/') && contains(github.ref, 'pre') && matrix.image_type == 'alpine' }},suffix= - type=raw,event=tag,value=prerelease-latest,enable=${{ startsWith(github.ref, 'refs/tags/') && contains(github.ref, 'pre') }},suffix=${{ env.SUFFIX }} - type=raw,event=tag,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/') && !contains(github.ref, 'pre') && matrix.image_type == 'alpine' }},suffix= - type=raw,event=tag,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/') && !contains(github.ref, 'pre') }},suffix=${{ env.SUFFIX }} - type=ref,event=pr,suffix=${{ env.SUFFIX }} - flavor: | - latest=false + tags: ${{ steps.meta.outputs.tags }} + flavor: latest=false - name: Login to Packages Container registry uses: docker/login-action@v3 @@ -112,11 +97,9 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Populate release version - # if: contains(fromJson('["push", "pull_request"]'), github.event_name) - run: echo "RELEASE_VERSION=${{ startsWith(github.ref, 'refs/tags/') && '${GITHUB_REF#refs/*/}' || 'dev' }}" >> $GITHUB_ENV + run: echo "RELEASE_VERSION=${{ startsWith(github.ref, 'refs/tags/') ? '${GITHUB_REF#refs/*/}' : 'dev' }}" >> $GITHUB_ENV - - name: "Build ${{ env.PUSH == 'true' && 'and push' || '' }} ${{ env.DOCKER_REPO }} image" - # if: contains(fromJson('["push", "pull_request"]'), github.event_name) + - name: Build and push ${{ env.PUSH == 'true' ? 'and push' : '' }} ${{ env.DOCKER_REPO }} image uses: docker/build-push-action@v5 with: cache-from: type=gha @@ -132,74 +115,26 @@ jobs: tags: ${{ steps.meta.outputs.tags }} target: ${{ matrix.image_type }} labels: ${{ steps.meta.outputs.labels }} - outputs: type=image,name=target,annotation-index.org.opencontainers.image.description=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.description'] }} - + outputs: type=registry - name: Echo environment variables run: | echo "Docker Repository: ${{ env.DOCKER_REPO }}" echo "Release Version: ${{ env.RELEASE_VERSION }}" - echo "Push Digest: ${{ steps.push.outputs.digest }}" + echo "Push Digest: ${{ steps.build-push.outputs.digest }}" - name: Generate artifact attestation - # if: ${{ env.PUSH == 'true' }} uses: actions/attest-build-provenance@v1 with: subject-name: ${{ env.DOCKER_REPO }}:${{ env.RELEASE_VERSION }} - subject-digest: ${{ steps.push.outputs.digest }} + subject-digest: ${{ steps.build-push.outputs.digest }} push-to-registry: true push: true - # test: - # needs: [changes] - # if: needs.changes.outputs.should-run-build == 'true' - # name: Test Image With Goss - # runs-on: ubuntu-24.04 - # strategy: - # matrix: - # image_type: [alpine, debian] - # env: - # DOCKER_REPO: ghcr.io/${{ github.repository }} - - # steps: - # - uses: actions/checkout@v4 - - # - name: Set up Docker Buildx - # uses: docker/setup-buildx-action@v3 - # with: - # driver-opts: | - # image=moby/buildkit:v0.14.0 - - # - name: "Build and load into Docker" - # if: contains(fromJson('["push", "pull_request"]'), github.event_name) - # uses: docker/build-push-action@v5 - # with: - # cache-from: type=gha - # cache-to: type=gha,mode=max - # context: . - # build-args: | - # ATLANTIS_BASE_TAG_TYPE=${{ matrix.image_type }} - # push: false - # load: true - # tags: "${{ env.DOCKER_REPO }}:goss-test" - # target: ${{ matrix.image_type }} - - # - name: "Setup Goss" - # uses: e1himself/goss-installation-action@v1.2.1 - # with: - # version: "v0.4.7" - - # - name: Execute Goss tests - # run: | - # dgoss run --rm ${{ env.DOCKER_REPO }}:goss-test bash -c 'while true; do sleep 1; done;' - skip-build: needs: [changes] if: needs.changes.outputs.should-run-build == 'false' - name: Build Image - strategy: - matrix: - image_type: [alpine, debian] + name: Skip Build runs-on: ubuntu-24.04 steps: - run: 'echo "No build required"'