Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions .github/workflows/build-docker-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 }}
Expand Down
33 changes: 26 additions & 7 deletions .github/workflows/push-docker-image-to-ecr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -23,30 +27,42 @@ 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
role-session-name: github-push-session

- 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'

Expand All @@ -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 }}"'
- 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"
19 changes: 15 additions & 4 deletions .github/workflows/run-in-docker-with-possible-artifact.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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: |
Expand All @@ -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
Expand Down
17 changes: 14 additions & 3 deletions .github/workflows/run-in-docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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: |
Expand Down
2 changes: 1 addition & 1 deletion actions/get-app-version/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions actions/setup-docker-image/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 }}
Expand Down