diff --git a/.github/workflows/build-docker-image.yaml b/.github/workflows/build-docker-image.yaml index 7ba0a6b..8973c42 100644 --- a/.github/workflows/build-docker-image.yaml +++ b/.github/workflows/build-docker-image.yaml @@ -3,6 +3,10 @@ name: Build docker image to ensure all steps exist in the cache on: workflow_call: inputs: + workflow-ref: + description: 'The ref of infoxchange/github-ci to use for actions' + required: true + type: string image-target: type: string outputs: @@ -17,19 +21,26 @@ jobs: name: Build docker image runs-on: ubuntu-latest outputs: - image-name: ${{ steps.build-docker-image.outputs.app-version }} + image-name: ${{ steps.build-docker-image.outputs.image-name }} app-version: ${{ steps.get-app-version.outputs.app-version }} steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v6 + + - name: Checkout github-ci actions + uses: actions/checkout@v6 + with: + repository: infoxchange/github-ci + ref: ${{ inputs.workflow-ref }} + path: .infoxchange-github-ci - name: Get app version id: get-app-version - uses: infoxchange/github-ci/actions/get-app-version@main + uses: ./.infoxchange-github-ci/actions/get-app-version - name: Build docker image id: build-docker-image - uses: infoxchange/github-ci/actions/setup-docker-image@main + uses: ./.infoxchange-github-ci/actions/setup-docker-image with: load-image: false target: ${{ inputs.image-target }} diff --git a/.github/workflows/push-docker-image-to-ecr.yaml b/.github/workflows/push-docker-image-to-ecr.yaml index 701843a..d524039 100644 --- a/.github/workflows/push-docker-image-to-ecr.yaml +++ b/.github/workflows/push-docker-image-to-ecr.yaml @@ -3,6 +3,10 @@ name: Run command in docker container on: workflow_call: inputs: + workflow-ref: + description: 'The ref of infoxchange/github-ci to use for actions' + required: true + type: string image-target: description: 'The build step target of the docker image' type: string @@ -23,22 +27,34 @@ jobs: contents: read steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v6 + + - name: Checkout github-ci actions + uses: actions/checkout@v6 + with: + repository: infoxchange/github-ci + ref: ${{ inputs.workflow-ref }} + path: .infoxchange-github-ci - name: Get app version id: get-app-version - uses: infoxchange/github-ci/actions/get-app-version@main + uses: ./.infoxchange-github-ci/actions/get-app-version + + - name: "ℹ️ Print info" + shell: bash + run: | + echo -e "Preparing to push tag: \e[1m${{ steps.get-app-version.outputs.app-version }}\e[0m" - name: Load docker image id: load-docker-image - uses: infoxchange/github-ci/actions/setup-docker-image@main + uses: ./.infoxchange-github-ci/actions/setup-docker-image with: target: ${{ inputs.image-target }} build-args: | APP_VERSION=${{ steps.get-app-version.outputs.app-version }} - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v2 + uses: aws-actions/configure-aws-credentials@v6.1.0 with: aws-region: ap-southeast-2 role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/GithubActionsOIDC @@ -46,7 +62,7 @@ jobs: - name: Login to Amazon ECR id: login-ecr - uses: aws-actions/amazon-ecr-login@v1 + uses: aws-actions/amazon-ecr-login@v2 with: mask-password: 'true' @@ -57,5 +73,8 @@ jobs: docker tag ${{ steps.load-docker-image.outputs.image-name }}:latest $ECR_REGISTRY/${{ inputs.ecr-image-name }}:${{ steps.get-app-version.outputs.app-version }} docker push $ECR_REGISTRY/${{ inputs.ecr-image-name }}:${{ steps.get-app-version.outputs.app-version }} - - name: Create image pushed notice - run: 'echo "::notice title=Image has been pushed to ECR::Image tag: ${{ steps.get-app-version.outputs.app-version }}"' \ No newline at end of file + - name: Print tag info + run: | + prefix_message="Pushed new tag to ECR:" + echo -e "### 🏷️ $prefix_message \n\`\`\`\n${{ steps.get-app-version.outputs.app-version }}\n\`\`\`" >> $GITHUB_STEP_SUMMARY + echo -e "$prefix_message\n\e[1m${{ steps.get-app-version.outputs.app-version }}\e[0m" \ No newline at end of file diff --git a/.github/workflows/run-in-docker-with-possible-artifact.yaml b/.github/workflows/run-in-docker-with-possible-artifact.yaml index f6782b4..6e7aab3 100644 --- a/.github/workflows/run-in-docker-with-possible-artifact.yaml +++ b/.github/workflows/run-in-docker-with-possible-artifact.yaml @@ -3,6 +3,10 @@ name: Run command in docker container and upload artifact if created on: workflow_call: inputs: + workflow-ref: + description: 'The ref of infoxchange/github-ci to use for actions' + required: true + type: string image-target: description: 'The build step target of the docker image' type: string @@ -29,15 +33,22 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v6 + + - name: Checkout github-ci actions + uses: actions/checkout@v6 + with: + repository: infoxchange/github-ci + ref: ${{ inputs.workflow-ref }} + path: .infoxchange-github-ci - name: Get app version id: get-app-version - uses: infoxchange/github-ci/actions/get-app-version@main + uses: ./.infoxchange-github-ci/actions/get-app-version - name: Setup docker image id: setup-docker-image - uses: infoxchange/github-ci/actions/setup-docker-image@main + uses: ./.infoxchange-github-ci/actions/setup-docker-image with: target: ${{ inputs.image-target }} build-args: | @@ -58,7 +69,7 @@ jobs: - name: Upload artifact if: ${{ always() }} - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 with: name: Mocha maps - screenshots path: testing-screenshots diff --git a/.github/workflows/run-in-docker.yaml b/.github/workflows/run-in-docker.yaml index 594274b..27c70c1 100644 --- a/.github/workflows/run-in-docker.yaml +++ b/.github/workflows/run-in-docker.yaml @@ -3,6 +3,10 @@ name: Run command in docker container on: workflow_call: inputs: + workflow-ref: + description: 'The ref of infoxchange/github-ci to use for actions' + required: true + type: string image-target: description: 'The build step target of the docker image' type: string @@ -20,15 +24,22 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v6 + + - name: Checkout github-ci actions + uses: actions/checkout@v6 + with: + repository: infoxchange/github-ci + ref: ${{ inputs.workflow-ref }} + path: .infoxchange-github-ci - name: Get app version id: get-app-version - uses: infoxchange/github-ci/actions/get-app-version@main + uses: ./.infoxchange-github-ci/actions/get-app-version - name: Setup docker image id: setup-docker-image - uses: infoxchange/github-ci/actions/setup-docker-image@main + uses: ./.infoxchange-github-ci/actions/setup-docker-image with: target: ${{ inputs.image-target }} build-args: | diff --git a/actions/get-app-version/action.yaml b/actions/get-app-version/action.yaml index 022062a..db9a81e 100644 --- a/actions/get-app-version/action.yaml +++ b/actions/get-app-version/action.yaml @@ -12,7 +12,7 @@ runs: - name: Get app version id: get-app-version shell: bash - run: echo "app-version=${{ github.ref_name }}-$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + run: echo "app-version=$(echo '${{ github.ref_name }}' | tr '/' '-')-$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT - name: Print app version shell: bash diff --git a/actions/setup-docker-image/action.yaml b/actions/setup-docker-image/action.yaml index a97a14a..ebcac43 100644 --- a/actions/setup-docker-image/action.yaml +++ b/actions/setup-docker-image/action.yaml @@ -9,7 +9,7 @@ inputs: load-image: description: 'Whether or not to load the image after creation' required: true - default: true + default: 'true' target: description: 'The build step target of the docker image' build-args: @@ -24,10 +24,10 @@ runs: using: "composite" steps: - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v4 - name: Build and export - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v7 with: context: . target: ${{ inputs.target }}