diff --git a/.github/workflows/docker_job.yml b/.github/workflows/docker_job.yml index eb3987801b..4e4a8ba935 100644 --- a/.github/workflows/docker_job.yml +++ b/.github/workflows/docker_job.yml @@ -12,6 +12,10 @@ on: default: ${{ github.ref }} required: false type: string + branch_name: + description: 'Branch name' + required: true + type: string defaults: run: @@ -25,6 +29,8 @@ permissions: jobs: docker_build_scan_push: + env: + BUILD_CACHE: /home/runner/.docker/buildkit strategy: fail-fast: false matrix: @@ -57,6 +63,28 @@ jobs: version: v0.15.1 platforms: linux/amd64,linux/arm64 + # - name: setup cache for ${{ matrix.ecr_repository }} + # id: setup_cache + # uses: actions/cache@v4.0.2 + # with: + # path: ${{ env.BUILD_CACHE }} + # key: ${{ inputs.checkout_tag }}-${{ matrix.ecr_repository }}-${{ hashFiles('go.mod', 'go.sum', 'package.json') }} + + - uses: unfor19/install-aws-cli-action@v1 + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v4.0.2 + with: + aws-region: eu-west-1 + role-to-assume: arn:aws:iam::311462405659:role/modernising-lpa-github-actions-ecr-push + role-duration-seconds: 900 + role-session-name: GithubActionsECRPushMLPAB + - name: ECR Login + id: login_ecr + uses: aws-actions/amazon-ecr-login@v2.0.1 + with: + mask-password: true + registries: 311462405659 + - name: Build ${{ matrix.ecr_repository }} Image uses: docker/build-push-action@v6.3.0 with: @@ -65,6 +93,8 @@ jobs: platforms: linux/amd64 push: false load: true + cache-from: type=registry,ref=${{ steps.login_ecr.outputs.registry }}/${{ matrix.ecr_repository }}:buildcache-${{ inputs.branch_name }} + cache-to: type=registry,ref=${{ steps.login_ecr.outputs.registry }}/${{ matrix.ecr_repository }}:buildcache-${{ inputs.branch_name }},mode=max tags: | ${{ matrix.ecr_repository }}:${{ inputs.tag }} build-args: | @@ -85,20 +115,20 @@ jobs: with: sarif_file: 'trivy-results.sarif' - - uses: unfor19/install-aws-cli-action@v1 - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v4.0.2 - with: - aws-region: eu-west-1 - role-to-assume: arn:aws:iam::311462405659:role/modernising-lpa-github-actions-ecr-push - role-duration-seconds: 900 - role-session-name: GithubActionsECRPushMLPAB - - name: ECR Login - id: login_ecr - uses: aws-actions/amazon-ecr-login@v2.0.1 - with: - mask-password: true - registries: 311462405659 + # - uses: unfor19/install-aws-cli-action@v1 + # - name: Configure AWS Credentials + # uses: aws-actions/configure-aws-credentials@v4.0.2 + # with: + # aws-region: eu-west-1 + # role-to-assume: arn:aws:iam::311462405659:role/modernising-lpa-github-actions-ecr-push + # role-duration-seconds: 900 + # role-session-name: GithubActionsECRPushMLPAB + # - name: ECR Login + # id: login_ecr_for_buildcache + # uses: aws-actions/amazon-ecr-login@v2.0.1 + # with: + # mask-password: true + # registries: 311462405659 - name: Push ${{ matrix.ecr_repository }} Image to ECR for PR if: ${{ github.workflow != 'Path To Live' }} uses: docker/build-push-action@v6.3.0 diff --git a/.github/workflows/workflow_pr.yml b/.github/workflows/workflow_pr.yml index d34f7446f2..fd27f3930c 100644 --- a/.github/workflows/workflow_pr.yml +++ b/.github/workflows/workflow_pr.yml @@ -58,6 +58,7 @@ jobs: ] with: tag: ${{ needs.create_tags.outputs.version_tag }} + branch_name: ${{ github.head_ref }} terraform_account_workflow_development: name: TF Plan Dev Account diff --git a/cmd/mlpa/build_trigger b/cmd/mlpa/build_trigger new file mode 100644 index 0000000000..3bceb603ee --- /dev/null +++ b/cmd/mlpa/build_trigger @@ -0,0 +1,26 @@ +this is a build trigger +another trigger +another build trigger +another build trigger +another build trigger +another build trigger +another build trigger +another build trigger +another build trigger +another build trigger +another build trigger +another build trigger +another build trigger +another build trigger +another build trigger +another build trigger +another build trigger +another build trigger +another build trigger +another build trigger +another build trigger +another build trigger +another build trigger +another build trigger +another build trigger +another build trigger