fix image tag #7
Workflow file for this run
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: CI/CD | |
on: | |
push: | |
permissions: | |
contents: read | |
jobs: | |
test: | |
name: Test application | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 | |
- name: Setup Go | |
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5 | |
with: | |
go-version-file: go.mod | |
cache: true | |
- name: Run tests | |
run: make test RELEASE_VERSION=0.0.0 | |
build-and-push: | |
name: Build and push Docker image and Helm chart | |
runs-on: ubuntu-latest | |
needs: [test] | |
env: | |
AWS_REGION_PUBLIC: us-east-1 | |
AWS_ROLE: arn:aws:iam::146628656107:role/cert-manager-controller-github-action-ecr-role | |
PUSH_IMAGE: ${{ (startsWith(github.ref, 'refs/tags/v') && contains(github.ref, 'teleport')) }} | |
ECR_REPO: public.ecr.aws/gravitational/cert-manager-controller | |
permissions: | |
contents: read | |
id-token: write # This is required for requesting the JWT, see https://github.com/aws-actions/configure-aws-credentials#OIDC | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup docker buildx | |
uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3 | |
- name: Configure AWS credentials for ECR Public | |
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4 | |
with: | |
aws-region: ${{ env.AWS_REGION_PUBLIC }} | |
role-to-assume: ${{ env.AWS_ROLE }} | |
if: ${{ env.PUSH_IMAGE == 'true' }} | |
- name: Login to Amazon ECR Public | |
id: login-ecr-public | |
uses: aws-actions/amazon-ecr-login@062b18b96a7aff071d4dc91bc00c4c1a7945b076 # v2 | |
with: | |
registry-type: public | |
if: ${{ env.PUSH_IMAGE == 'true' }} | |
- name: Prepare docker labels and tags | |
id: meta | |
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5 | |
with: | |
# enable public repo only for tags | |
images: | | |
name=${{ env.ECR_REPO }},enable=${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') }} | |
flavor: | | |
latest=false | |
tags: | | |
type=sha,prefix={{branch}}-,suffix=-{{date 'YYYYMMDDTHHmmss'}},format=short,enable=${{ startsWith(github.ref, 'refs/heads/') }} | |
type=semver,pattern={{version}},enable=${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') }} | |
- name: Prepare docker image | |
run: make cert-manager-controller-linux TAG=${{ env.ECR_REPO }}:${{ steps.meta.outputs.tags }} | |
- name: Build the Docker image and push | |
uses: docker/build-push-action@5cd11c3a4ced054e52742c5fd54dca954e0edd85 # v6 | |
with: | |
push: ${{ env.PUSH_IMAGE }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
build-args: | | |
BASE_IMAGE=gcr.io/distroless/static-debian12 | |
file: hack/containers/Containerfile.controller | |
platforms: | | |
linux/amd64 | |
linux/arm64 |