Skip to content

Commit

Permalink
Update atlantis-image.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
yoonhyunwoo authored Aug 1, 2024
1 parent 92ed965 commit 2393867
Showing 1 changed file with 10 additions and 75 deletions.
85 changes: 10 additions & 75 deletions .github/workflows/atlantis-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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/[email protected]
# 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"'

0 comments on commit 2393867

Please sign in to comment.