Skip to content

build-containers

build-containers #24

name: build-containers
on:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }}
cancel-in-progress: false
permissions:
contents: read
id-token: write # required for OIDC
jobs:
changes:
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
packages: ${{ steps.filter.outputs.changes }}
steps:
# For pull requests it's not necessary to checkout the code
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
actions-runner-iac: platform/actions-runner-iac
aws-cli-v2: platform/aws-cli-v2
k8s-toolkit-diag: platform/k8s-toolkit-diag
k8s-toolkit-set-1: platform/k8s-toolkit-set-1
k8s-toolkit-set-2: platform/k8s-toolkit-set-2
k8s-toolkit-set-3: platform/k8s-toolkit-set-3
terraform-tfcmt: platform/terraform-tfcmt
terraform-cicd: platform/terraform-cicd
build-matrix:
runs-on: ubuntu-latest
needs: changes
strategy:
fail-fast: false
matrix:
image: ${{ fromJSON(needs.changes.outputs.packages) }}
steps:
- uses: actions/checkout@v3
- name: "aws:configure-credentials"
uses: aws-actions/configure-aws-credentials@v1
id: aws-credentials
with:
role-to-assume: "arn:aws:iam::${{ secrets.RAFTECH_AWS_ACCOUNT_ID }}:role/GithubActionsRole"
role-session-name: "raftech-public-ecr-gha"
aws-region: "us-east-1"
mask-aws-account-id: no
- name: "aws:login-to-ecr"
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
with:
registry-type: "public"
- name: "docker:setup-buildx"
uses: docker/setup-buildx-action@v3
- name: "docker:setup-metadata"
id: metadata
uses: docker/[email protected]
with:
images: ${{ steps.login-ecr.outputs.registry }}/p8o7f1g4/platform/${{ matrix.image }}
tags: |
# type=ref,event=branch
# type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha
-
name: docker::build-and-push
id: push
uses: docker/[email protected]
with:
context: "./platform/${{ matrix.image }}"
push: true
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}