From edbec1de375c70a9b3d92ad7a79b701a9082603a Mon Sep 17 00:00:00 2001 From: Mohamed ElSayed Date: Tue, 22 Oct 2024 16:01:44 +1100 Subject: [PATCH 1/3] chore: Use our default "ci" reusable github actions workflow to build docker images --- .github/workflows/publish.yml | 46 ++++++++++++----------------------- .github/workflows/test.yml | 16 ++++++++++++ 2 files changed, 32 insertions(+), 30 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 6b73e8b..11c5f8c 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -15,38 +15,24 @@ permissions: env: MISE_PYTHON_COMPILE: false GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + AWS_IAM_ROLE: "" jobs: - push_to_registry: - name: Push Docker image to Docker Hub - runs-on: ubuntu-latest - steps: - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v2 - with: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws-region: ap-southeast-2 - - - name: Docker Login to Amazon ECR - id: login-ecr - uses: aws-actions/amazon-ecr-login@v1 - - - name: Check out the repo - uses: actions/checkout@v3 - - - name: Pull latest image. Build docker image and publish it. - env: - latest_image: 305686791668.dkr.ecr.ap-southeast-2.amazonaws.com/gitops:latest - current_image: 305686791668.dkr.ecr.ap-southeast-2.amazonaws.com/gitops:${{github.event.release.tag_name}} - run: | - echo ${{secrets.CLUSTER_KEY}} | base64 -d > cluster.key - docker pull $latest_image - docker build -t $latest_image --cache-from $latest_image . - docker push $latest_image - docker tag $latest_image $current_image - docker push $current_image - echo "Published image at: $current_image" + build: + name: Build and Push Docker Image + uses: uptick/actions/.github/workflows/ci.yaml@main + secrets: + SECRET_ENV: "${{ secrets.CLUSTER_KEY }}" + #https://github.com/uptick/actions/blob/main/.github/workflows/ci.yaml + with: + aws-iam-role-arn: "arn:aws:iam::305686791668:role/default-github-actions-ci-role" + docker-enabled: true + docker-context: "." + docker-tag: ${{github.event.release.tag_name}} + docker-tag-latest: true + docker-image-platforms: linux/amd64 + docker-repository: "305686791668.dkr.ecr.ap-southeast-2.amazonaws.com/gitops" + command: echo $SECRET_ENV | base64 -d > cluster.key publish_helm_chart: runs-on: ubuntu-latest diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4859404..d04b10e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,3 +24,19 @@ jobs: command: | mise run install mise run ci + build: + name: Build and Push Docker Image + uses: uptick/actions/.github/workflows/ci.yaml@main + secrets: + SECRET_ENV: "${{ secrets.CLUSTER_KEY }}" + #https://github.com/uptick/actions/blob/main/.github/workflows/ci.yaml + with: + aws-iam-role-arn: "arn:aws:iam::305686791668:role/default-github-actions-ci-role" + docker-enabled: true + docker-context: "." + docker-prefix: test + docker-tag-latest: false + docker-image-platforms: linux/amd64 + docker-repository: "305686791668.dkr.ecr.ap-southeast-2.amazonaws.com/gitops" + command: echo $SECRET_ENV | base64 -d > cluster.key + From 845addf2ec038c988a700db3649e117308e1c05f Mon Sep 17 00:00:00 2001 From: Mohamed ElSayed Date: Thu, 24 Oct 2024 12:01:17 +1100 Subject: [PATCH 2/3] chore: Remove uneeded env variable --- .github/workflows/publish.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 11c5f8c..6a1a34f 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -15,7 +15,6 @@ permissions: env: MISE_PYTHON_COMPILE: false GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - AWS_IAM_ROLE: "" jobs: build: From 98dfa58652e34981481276960d685d8bc5fae65b Mon Sep 17 00:00:00 2001 From: Mohamed ElSayed Date: Thu, 24 Oct 2024 14:12:05 +1100 Subject: [PATCH 3/3] chore: Build only without push on test --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d04b10e..413a892 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -37,6 +37,7 @@ jobs: docker-prefix: test docker-tag-latest: false docker-image-platforms: linux/amd64 + docker-push: false docker-repository: "305686791668.dkr.ecr.ap-southeast-2.amazonaws.com/gitops" command: echo $SECRET_ENV | base64 -d > cluster.key