Skip to content

Commit

Permalink
feat(ci): enhance process
Browse files Browse the repository at this point in the history
  • Loading branch information
alimd committed Nov 27, 2023
1 parent 85a422d commit 3b67ae2
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions .github/workflows/publish-container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,15 @@ jobs:

- name: ❔ Check Container files changed
id: file_change
if: ${{ github.event_name != 'release' && github.event_name != 'workflow_dispatch' }}
uses: dorny/[email protected]
with:
filters: |
container_folder:
./${{ matrix.path }}/*
- name: πŸ— Extract version from dockerfile
if: ${{ steps.file_change.outputs.container_folder == 'true' }}
if: ${{ steps.file_change.outputs.container_folder != 'false' }}
id: version
run: |
version_full=$(grep 'cloud.alwatr.image.version.full' ./${{ matrix.path }}/Dockerfile | cut -d'"' -f2)
Expand All @@ -105,37 +106,37 @@ jobs:
echo "version_short: $version_short"
- name: πŸ— Install cosign
if: ${{ github.event_name != 'pull_request' && steps.file_change.outputs.container_folder == 'true' }}
if: ${{ github.event_name != 'pull_request' && steps.file_change.outputs.container_folder != 'false' }}
uses: sigstore/[email protected]

- name: πŸ— Setup Docker Buildx
if: ${{ steps.file_change.outputs.container_folder == 'true' }}
if: ${{ steps.file_change.outputs.container_folder != 'false' }}
uses: docker/[email protected]

- name: πŸ— Cache Docker Layers
if: ${{ steps.file_change.outputs.container_folder == 'true' }}
if: ${{ steps.file_change.outputs.container_folder != 'false' }}
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: container-${{ matrix.name }}
key: container/${{ matrix.path }}

- name: πŸ— Log into docker hub registry
if: ${{ github.event_name != 'pull_request' && steps.file_change.outputs.container_folder == 'true' }}
if: ${{ github.event_name != 'pull_request' && steps.file_change.outputs.container_folder != 'false' }}
uses: docker/[email protected]
with:
username: ${{env.USER}}
password: ${{secrets.DOCKER_HUB_TOKEN}}

- name: πŸ— Log into ghcr.io registry
if: ${{ github.event_name != 'pull_request' && steps.file_change.outputs.container_folder == 'true' }}
if: ${{ github.event_name != 'pull_request' && steps.file_change.outputs.container_folder != 'false' }}
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{env.USER}}
password: ${{secrets.GITHUB_TOKEN}}

- name: πŸš€ Build and push container image
if: ${{ steps.file_change.outputs.container_folder == 'true' }}
if: ${{ steps.file_change.outputs.container_folder != 'false' }}
id: build_and_push
uses: docker/[email protected]
with:
Expand All @@ -152,12 +153,12 @@ jobs:
BUILD_DATE=${{github.event.repository.updated_at}}
BUILD_REV=${{github.sha}}
- name: πŸ— Sign the image with GitHub OIDC Token
if: ${{ github.event_name != 'pull_request' && steps.file_change.outputs.container_folder == 'true' }}
env:
COSIGN_EXPERIMENTAL: 'true'
run: |
cosign sign --yes "ghcr.io/${{env.USER}}/${{matrix.name}}:${{steps.version.outputs.version_full}}@${{steps.build_and_push.outputs.digest}}"
cosign sign --yes "ghcr.io/${{env.USER}}/${{matrix.name}}:${{steps.version.outputs.version_short}}@${{steps.build_and_push.outputs.digest}}"
cosign sign --yes "docker.io/${{env.USER}}/${{matrix.name}}:${{steps.version.outputs.version_full}}@${{steps.build_and_push.outputs.digest}}"
cosign sign --yes "docker.io/${{env.USER}}/${{matrix.name}}:${{steps.version.outputs.version_short}}@${{steps.build_and_push.outputs.digest}}"
# - name: πŸ— Sign the image with GitHub OIDC Token
# if: ${{ github.event_name != 'pull_request' && steps.file_change.outputs.container_folder != 'false' }}
# env:
# COSIGN_EXPERIMENTAL: 'true'
# run: |
# cosign sign --yes "ghcr.io/${{env.USER}}/${{matrix.name}}:${{steps.version.outputs.version_full}}@${{steps.build_and_push.outputs.digest}}"
# cosign sign --yes "ghcr.io/${{env.USER}}/${{matrix.name}}:${{steps.version.outputs.version_short}}@${{steps.build_and_push.outputs.digest}}"
# cosign sign --yes "docker.io/${{env.USER}}/${{matrix.name}}:${{steps.version.outputs.version_full}}@${{steps.build_and_push.outputs.digest}}"
# cosign sign --yes "docker.io/${{env.USER}}/${{matrix.name}}:${{steps.version.outputs.version_short}}@${{steps.build_and_push.outputs.digest}}"

0 comments on commit 3b67ae2

Please sign in to comment.