fix(workflows): package path #721
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: "Build & Push" | |
on: | |
push: | |
branches: | |
- "main" | |
tags: | |
- "*" | |
paths: | |
- "packages/**" | |
- "!packages/*/scripts/**" | |
- ".github/workflows/build-push.yaml" | |
jobs: | |
find_dockerfiles: | |
name: Find Dockerfiles | |
runs-on: ubuntu-latest | |
outputs: | |
packages: ${{ steps.set_packages_output.outputs.packages }} | |
steps: | |
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 | |
- name: Find packages | |
id: set_packages_output | |
run: | | |
PACKAGES=$(find packages -type f -path "*/Dockerfile" | awk -F'/' '{print $2}' | jq -R -s -c 'split("\n")[:-1]') | |
echo "packages=$PACKAGES" >> $GITHUB_OUTPUT | |
build_push_image: | |
name: ${{ matrix.package }} | |
needs: [find_dockerfiles] | |
runs-on: ubuntu-latest | |
environment: dev | |
permissions: | |
contents: read | |
id-token: write | |
strategy: | |
fail-fast: false | |
matrix: | |
package: ${{ fromJson(needs.find_dockerfiles.outputs.packages) }} | |
env: | |
DOCKER_BUILD_SUMMARY: "false" | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4 | |
with: | |
aws-region: ${{ vars.AWS_REGION }} | |
role-to-assume: ${{ vars.IAM_ROLE_ARN }} | |
role-session-name: be-monorepo-build-push-${{ github.run_number }} | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@062b18b96a7aff071d4dc91bc00c4c1a7945b076 # v2 | |
- name: (latest) Docker metadata | |
id: meta_latest | |
if: ${{ github.ref_type == 'branch' }} | |
uses: docker/metadata-action@60a0d343a0d8a18aedee9d34e62251f752153bdb | |
with: | |
images: ${{ steps.login-ecr.outputs.registry }}/interop-be-${{ matrix.package }} | |
flavor: | | |
latest=false | |
prefix= | |
suffix= | |
tags: | | |
type=raw,value=2.x-latest | |
- name: (tag) Docker metadata | |
id: meta_tag | |
if: ${{ github.ref_type == 'tag' }} | |
uses: docker/metadata-action@60a0d343a0d8a18aedee9d34e62251f752153bdb | |
with: | |
images: ${{ steps.login-ecr.outputs.registry }}/interop-be-${{ matrix.package }} | |
flavor: | | |
latest=false | |
prefix= | |
suffix= | |
tags: | | |
type=ref,event=tag | |
- name: Build and push Docker image | |
id: build_push | |
uses: docker/build-push-action@a8d35412fb758de9162fd63e3fa3f0942bdedb4d | |
with: | |
context: . | |
file: packages/${{ matrix.package }}/Dockerfile | |
push: true | |
tags: ${{ github.ref_type == 'branch' && steps.meta_latest.outputs.tags || steps.meta_tag.outputs.tags }} | |
labels: ${{ github.ref_type == 'branch' && steps.meta_latest.outputs.labels || steps.meta_tag.outputs.labels }} |