From 8c869ce3880a0de93709a9ea8ff1b5591b3b8c46 Mon Sep 17 00:00:00 2001 From: kynmh69 Date: Sat, 30 Mar 2024 11:52:40 +0900 Subject: [PATCH 01/21] feature mod workflows #32 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 186b771..51df864 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # go-ja-holidays -[![Create api image](https://github.com/kynmh69/go-ja-holidays/actions/workflows/docker-publish-api.yml/badge.svg)](https://github.com/kynmh69/go-ja-holidays/actions/workflows/docker-publish-api.yml) [![Create updater image](https://github.com/kynmh69/go-ja-holidays/actions/workflows/docker-publish-updater.yml/badge.svg?branch=main)](https://github.com/kynmh69/go-ja-holidays/actions/workflows/docker-publish-updater.yml) [![CodeQL](https://github.com/kynmh69/go-ja-holidays/actions/workflows/codeql.yml/badge.svg)](https://github.com/kynmh69/go-ja-holidays/actions/workflows/codeql.yml) [![Go Test](https://github.com/kynmh69/go-ja-holidays/actions/workflows/go.yml/badge.svg)](https://github.com/kynmh69/go-ja-holidays/actions/workflows/go.yml) [![codecov](https://codecov.io/gh/kynmh69/go-ja-holidays/graph/badge.svg?token=1OTK685UWI)](https://codecov.io/gh/kynmh69/go-ja-holidays) +[![Create api image](https://github.com/kynmh69/go-ja-holidays/actions/workflows/docker-publish-api.yml/badge.svg)](https://github.com/kynmh69/go-ja-holidays/actions/workflows/docker-publish-api.yml) [![Create updater image](https://github.com/kynmh69/go-ja-holidays/actions/workflows/docker-publish-updater.yml/badge.svg?branch=main)](https://github.com/kynmh69/go-ja-holidays/actions/workflows/docker-publish-updater.yml) [![Create Key Manager image](https://github.com/kynmh69/go-ja-holidays/actions/workflows/docker-publish-key-manager.yml/badge.svg)](https://github.com/kynmh69/go-ja-holidays/actions/workflows/docker-publish-key-manager.yml) [![codecov](https://codecov.io/gh/kynmh69/go-ja-holidays/graph/badge.svg?token=1OTK685UWI)](https://codecov.io/gh/kynmh69/go-ja-holidays) 日本の祝日を返却するAPIを提供します。 From 1fe9f3dfe80e5e7611b95ae0e02ba40cbe2a7098 Mon Sep 17 00:00:00 2001 From: kynmh69 Date: Sat, 30 Mar 2024 11:53:25 +0900 Subject: [PATCH 02/21] feature mod workflows #32 --- .github/workflows/docker-publish-key-manager.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-publish-key-manager.yml b/.github/workflows/docker-publish-key-manager.yml index 05e4cd5..e36387a 100644 --- a/.github/workflows/docker-publish-key-manager.yml +++ b/.github/workflows/docker-publish-key-manager.yml @@ -126,7 +126,7 @@ jobs: MODE: atomic run: go test -v ./... - publish-api: + publish-key-manager: needs: test-key-manager runs-on: ubuntu-latest permissions: From 25cdb519d96672cc1a85112b60ddef9faa9f6e07 Mon Sep 17 00:00:00 2001 From: kynmh69 Date: Sat, 30 Mar 2024 13:55:01 +0900 Subject: [PATCH 03/21] feature add create ecs service #28 --- .github/workflows/docker-publish-updater.yml | 63 +++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker-publish-updater.yml b/.github/workflows/docker-publish-updater.yml index fb595c1..e65993e 100644 --- a/.github/workflows/docker-publish-updater.yml +++ b/.github/workflows/docker-publish-updater.yml @@ -10,15 +10,27 @@ on: branches: [ "main" ] # Publish semver tags as releases. tags: [ 'v*.*.*' ] + paths: + - 'src/**' + - '.github/workflows/**' pull_request: branches: [ "main" ] - + paths: + - 'src/**' + - '.github/workflows/**' env: # Use docker.io for Docker Hub if empty REGISTRY: ghcr.io # github.repository as / IMAGE_NAME: ${{ github.repository }} UPDATER_DIR: "src/updater" + AWS_REGION: us-west-2 + ECR_REPOSITORY: "go-ja-holidays-updater" + ECS_SERVICE: holidays-updater-service + ECS_CLUSTER: holidays-cluster + ECS_TASK_DEFINITION: .aws/updater_task.json + CONTAINER_NAME: MY_CONTAINER_NAME + jobs: @@ -198,3 +210,52 @@ jobs: # This step uses the identity token to provision an ephemeral certificate # against the sigstore community Fulcio instance. run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST} + + deploy: + needs: test-updater + name: Deploy to ECR + runs-on: ubuntu-latest + environment: production + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: ${{ secrets.ASSUME_ROLE }} + aws-region: ${{ env.AWS_REGION }} + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v1 + + - name: Build, tag, and push image to Amazon ECR + id: build-image + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + IMAGE_TAG: ${{ github.sha }} + run: | + # Build a docker container and + # push it to ECR so that it can + # be deployed to ECS. + docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . + docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG + echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT + + # - name: Fill in the new image ID in the Amazon ECS task definition + # id: task-def + # uses: aws-actions/amazon-ecs-render-task-definition@v1 + # with: + # task-definition: ${{ env.ECS_TASK_DEFINITION }} + # container-name: ${{ env.CONTAINER_NAME }} + # image: ${{ steps.build-image.outputs.image }} + + # - name: Deploy Amazon ECS task definition + # uses: aws-actions/amazon-ecs-deploy-task-definition@v1 + # with: + # task-definition: ${{ steps.task-def.outputs.task-definition }} + # service: ${{ env.ECS_SERVICE }} + # cluster: ${{ env.ECS_CLUSTER }} + # wait-for-service-stability: true From 83231ce2488ee3bf108ad19b3f482c0f693488aa Mon Sep 17 00:00:00 2001 From: kynmh69 Date: Sat, 30 Mar 2024 14:05:31 +0900 Subject: [PATCH 04/21] feature add create ecs service #28 --- .github/workflows/docker-publish-updater.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-publish-updater.yml b/.github/workflows/docker-publish-updater.yml index e65993e..147577c 100644 --- a/.github/workflows/docker-publish-updater.yml +++ b/.github/workflows/docker-publish-updater.yml @@ -31,8 +31,6 @@ env: ECS_TASK_DEFINITION: .aws/updater_task.json CONTAINER_NAME: MY_CONTAINER_NAME - - jobs: analyze: name: Analyze @@ -212,6 +210,8 @@ jobs: run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST} deploy: + permissions: + id-token: write needs: test-updater name: Deploy to ECR runs-on: ubuntu-latest From 18a403a95910726e2ba1df57c4d1def7cef3c7f3 Mon Sep 17 00:00:00 2001 From: kynmh69 Date: Sat, 30 Mar 2024 14:14:54 +0900 Subject: [PATCH 05/21] feature add create ecs service #28 --- .github/workflows/docker-publish-updater.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/docker-publish-updater.yml b/.github/workflows/docker-publish-updater.yml index 147577c..502e148 100644 --- a/.github/workflows/docker-publish-updater.yml +++ b/.github/workflows/docker-publish-updater.yml @@ -24,6 +24,7 @@ env: # github.repository as / IMAGE_NAME: ${{ github.repository }} UPDATER_DIR: "src/updater" + DOCKER_FILE: "docker/updater" AWS_REGION: us-west-2 ECR_REPOSITORY: "go-ja-holidays-updater" ECS_SERVICE: holidays-updater-service @@ -233,6 +234,7 @@ jobs: - name: Build, tag, and push image to Amazon ECR id: build-image + working-directory: ${{ env.DOCKER_FILE }} env: ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} IMAGE_TAG: ${{ github.sha }} From 3a7971fb26e73aa66cc8c6aa7c56d8c213976a18 Mon Sep 17 00:00:00 2001 From: kynmh69 Date: Sat, 30 Mar 2024 14:19:51 +0900 Subject: [PATCH 06/21] feature add create ecs service #28 --- .github/workflows/docker-publish-api.yml | 12 ++++++++++++ .github/workflows/docker-publish-key-manager.yml | 12 ++++++++++++ .github/workflows/docker-publish-updater.yml | 13 +++++++++---- 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker-publish-api.yml b/.github/workflows/docker-publish-api.yml index 76c3fe4..0f1a2a0 100644 --- a/.github/workflows/docker-publish-api.yml +++ b/.github/workflows/docker-publish-api.yml @@ -10,8 +10,20 @@ on: branches: [ "main" ] # Publish semver tags as releases. tags: [ 'v*.*.*' ] + paths: + - 'src/api/**' + - 'src/middleware/**' + - 'src/model/**' + - 'src/util/**' + - '.github/workflows/**' pull_request: branches: [ "main" ] + paths: + - 'src/api/**' + - 'src/middleware/**' + - 'src/model/**' + - 'src/util/**' + - '.github/workflows/**' env: # Use docker.io for Docker Hub if empty diff --git a/.github/workflows/docker-publish-key-manager.yml b/.github/workflows/docker-publish-key-manager.yml index e36387a..b741a9c 100644 --- a/.github/workflows/docker-publish-key-manager.yml +++ b/.github/workflows/docker-publish-key-manager.yml @@ -10,8 +10,20 @@ on: branches: [ "main" ] # Publish semver tags as releases. tags: [ 'v*.*.*' ] + paths: + - 'src/key_management/**' + - 'src/middleware/**' + - 'src/model/**' + - 'src/util/**' + - '.github/workflows/**' pull_request: branches: [ "main" ] + paths: + - 'src/key_management/**' + - 'src/middleware/**' + - 'src/model/**' + - 'src/util/**' + - '.github/workflows/**' env: # Use docker.io for Docker Hub if empty diff --git a/.github/workflows/docker-publish-updater.yml b/.github/workflows/docker-publish-updater.yml index 502e148..f88ef85 100644 --- a/.github/workflows/docker-publish-updater.yml +++ b/.github/workflows/docker-publish-updater.yml @@ -11,12 +11,18 @@ on: # Publish semver tags as releases. tags: [ 'v*.*.*' ] paths: - - 'src/**' + - 'src/updater/**' + - 'src/middleware/**' + - 'src/model/**' + - 'src/util/**' - '.github/workflows/**' pull_request: branches: [ "main" ] paths: - - 'src/**' + - 'src/updater/**' + - 'src/middleware/**' + - 'src/model/**' + - 'src/util/**' - '.github/workflows/**' env: # Use docker.io for Docker Hub if empty @@ -234,7 +240,6 @@ jobs: - name: Build, tag, and push image to Amazon ECR id: build-image - working-directory: ${{ env.DOCKER_FILE }} env: ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} IMAGE_TAG: ${{ github.sha }} @@ -242,7 +247,7 @@ jobs: # Build a docker container and # push it to ECR so that it can # be deployed to ECS. - docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . + docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG ./docker/updater/Dockerfile docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT From 4aa547aad7f3c0dd07343f2f1ff62b7abb1652e7 Mon Sep 17 00:00:00 2001 From: kynmh69 Date: Sat, 30 Mar 2024 14:28:03 +0900 Subject: [PATCH 07/21] feature add create ecs service #28 --- .github/workflows/docker-publish-api.yml | 4 ++-- .github/workflows/docker-publish-key-manager.yml | 4 ++-- .github/workflows/docker-publish-updater.yml | 7 ++++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/docker-publish-api.yml b/.github/workflows/docker-publish-api.yml index 0f1a2a0..96a8346 100644 --- a/.github/workflows/docker-publish-api.yml +++ b/.github/workflows/docker-publish-api.yml @@ -15,7 +15,7 @@ on: - 'src/middleware/**' - 'src/model/**' - 'src/util/**' - - '.github/workflows/**' + - '.github/workflows/docker-publish-api.yml' pull_request: branches: [ "main" ] paths: @@ -23,7 +23,7 @@ on: - 'src/middleware/**' - 'src/model/**' - 'src/util/**' - - '.github/workflows/**' + - '.github/workflows/docker-publish-api.yml' env: # Use docker.io for Docker Hub if empty diff --git a/.github/workflows/docker-publish-key-manager.yml b/.github/workflows/docker-publish-key-manager.yml index b741a9c..720ea2a 100644 --- a/.github/workflows/docker-publish-key-manager.yml +++ b/.github/workflows/docker-publish-key-manager.yml @@ -15,7 +15,7 @@ on: - 'src/middleware/**' - 'src/model/**' - 'src/util/**' - - '.github/workflows/**' + - '.github/workflows/docker-publish-key-manager.yml' pull_request: branches: [ "main" ] paths: @@ -23,7 +23,7 @@ on: - 'src/middleware/**' - 'src/model/**' - 'src/util/**' - - '.github/workflows/**' + - '.github/workflows/docker-publish-key-manager.yml' env: # Use docker.io for Docker Hub if empty diff --git a/.github/workflows/docker-publish-updater.yml b/.github/workflows/docker-publish-updater.yml index f88ef85..7e1c3d6 100644 --- a/.github/workflows/docker-publish-updater.yml +++ b/.github/workflows/docker-publish-updater.yml @@ -15,7 +15,7 @@ on: - 'src/middleware/**' - 'src/model/**' - 'src/util/**' - - '.github/workflows/**' + - '.github/workflows/docker-publish-updater.yml' pull_request: branches: [ "main" ] paths: @@ -23,7 +23,7 @@ on: - 'src/middleware/**' - 'src/model/**' - 'src/util/**' - - '.github/workflows/**' + - '.github/workflows/docker-publish-updater.yml' env: # Use docker.io for Docker Hub if empty REGISTRY: ghcr.io @@ -247,7 +247,8 @@ jobs: # Build a docker container and # push it to ECR so that it can # be deployed to ECS. - docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG ./docker/updater/Dockerfile + ls -l + docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG docker/updater/Dockerfile docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT From 2534bb030b12134fdd1ebb97474099d1e492c74f Mon Sep 17 00:00:00 2001 From: kynmh69 Date: Sat, 30 Mar 2024 14:34:51 +0900 Subject: [PATCH 08/21] feature add create ecs service #28 --- .github/workflows/codecov.yml | 6 ++++++ .github/workflows/docker-publish-updater.yml | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index 93c6128..985e2ac 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -5,9 +5,15 @@ on: - main tags: - 'v*.*.*' + paths: + - '.github/workflows/codecov.yml' + - 'src/**' pull_request: branches: - main + paths: + - '.github/workflows/codecov.yml' + - 'src/**' env: UPDATER_DIR: "src/updater" API_DIR: "src/api" diff --git a/.github/workflows/docker-publish-updater.yml b/.github/workflows/docker-publish-updater.yml index 7e1c3d6..6f76c94 100644 --- a/.github/workflows/docker-publish-updater.yml +++ b/.github/workflows/docker-publish-updater.yml @@ -248,7 +248,7 @@ jobs: # push it to ECR so that it can # be deployed to ECS. ls -l - docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG docker/updater/Dockerfile + docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -f docker/updater/Dockerfile . docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT From b7272e5577c9efc463a10cfa89e27c1f86831255 Mon Sep 17 00:00:00 2001 From: kynmh69 Date: Sat, 30 Mar 2024 14:51:39 +0900 Subject: [PATCH 09/21] feature add create ecs service #28 --- .github/workflows/docker-publish-updater.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/docker-publish-updater.yml b/.github/workflows/docker-publish-updater.yml index 6f76c94..3f8b634 100644 --- a/.github/workflows/docker-publish-updater.yml +++ b/.github/workflows/docker-publish-updater.yml @@ -237,6 +237,9 @@ jobs: - name: Login to Amazon ECR id: login-ecr uses: aws-actions/amazon-ecr-login@v1 + with: + mask-password: 'true' + registry-type: public - name: Build, tag, and push image to Amazon ECR id: build-image From b38db2684b7a4b66254144dd8f2169176cf3f76c Mon Sep 17 00:00:00 2001 From: kynmh69 Date: Sat, 30 Mar 2024 14:55:58 +0900 Subject: [PATCH 10/21] feature add create ecs service #28 --- .github/workflows/docker-publish-updater.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-publish-updater.yml b/.github/workflows/docker-publish-updater.yml index 3f8b634..a07ffa5 100644 --- a/.github/workflows/docker-publish-updater.yml +++ b/.github/workflows/docker-publish-updater.yml @@ -31,7 +31,7 @@ env: IMAGE_NAME: ${{ github.repository }} UPDATER_DIR: "src/updater" DOCKER_FILE: "docker/updater" - AWS_REGION: us-west-2 + AWS_REGION: us-east-1 ECR_REPOSITORY: "go-ja-holidays-updater" ECS_SERVICE: holidays-updater-service ECS_CLUSTER: holidays-cluster From f993c6b577dc20dd6899152a1ddf074fa581a6bf Mon Sep 17 00:00:00 2001 From: kynmh69 Date: Sat, 30 Mar 2024 15:08:12 +0900 Subject: [PATCH 11/21] feature add create ecs service #28 --- .github/workflows/docker-publish-updater.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/docker-publish-updater.yml b/.github/workflows/docker-publish-updater.yml index a07ffa5..ae8933c 100644 --- a/.github/workflows/docker-publish-updater.yml +++ b/.github/workflows/docker-publish-updater.yml @@ -32,7 +32,7 @@ env: UPDATER_DIR: "src/updater" DOCKER_FILE: "docker/updater" AWS_REGION: us-east-1 - ECR_REPOSITORY: "go-ja-holidays-updater" + ECR_REPOSITORY: "j9l1s4z2/go-ja-holidays-updater" ECS_SERVICE: holidays-updater-service ECS_CLUSTER: holidays-cluster ECS_TASK_DEFINITION: .aws/updater_task.json @@ -250,7 +250,6 @@ jobs: # Build a docker container and # push it to ECR so that it can # be deployed to ECS. - ls -l docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -f docker/updater/Dockerfile . docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT From b25974458e7fb092ccefc1291426bbcea443094b Mon Sep 17 00:00:00 2001 From: kynmh69 Date: Sat, 30 Mar 2024 17:27:41 +0900 Subject: [PATCH 12/21] feature add create ecs service #28 --- .github/workflows/docker-publish-api.yml | 60 +++++++++++++++++++ .../workflows/docker-publish-key-manager.yml | 60 +++++++++++++++++++ 2 files changed, 120 insertions(+) diff --git a/.github/workflows/docker-publish-api.yml b/.github/workflows/docker-publish-api.yml index 96a8346..eff9341 100644 --- a/.github/workflows/docker-publish-api.yml +++ b/.github/workflows/docker-publish-api.yml @@ -31,6 +31,12 @@ env: # github.repository as / IMAGE_NAME: ${{ github.repository }} API_DIR: "src/api" + AWS_REGION: us-east-1 + ECR_REPOSITORY: "j9l1s4z2/go-ja-holidays-api" + ECS_SERVICE: holidays-api-service + ECS_CLUSTER: holidays-cluster + ECS_TASK_DEFINITION: .aws/api_task.json + CONTAINER_NAME: MY_CONTAINER_NAME jobs: @@ -213,3 +219,57 @@ jobs: # This step uses the identity token to provision an ephemeral certificate # against the sigstore community Fulcio instance. run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST} + + deploy: + permissions: + id-token: write + needs: test-updater + name: Deploy to ECR + runs-on: ubuntu-latest + environment: production + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: ${{ secrets.ASSUME_ROLE }} + aws-region: ${{ env.AWS_REGION }} + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v1 + with: + mask-password: 'true' + registry-type: public + + - name: Build, tag, and push image to Amazon ECR + id: build-image + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + IMAGE_TAG: ${{ github.sha }} + run: | + # Build a docker container and + # push it to ECR so that it can + # be deployed to ECS. + docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -f docker/api/Dockerfile . + docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG + echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT + + # - name: Fill in the new image ID in the Amazon ECS task definition + # id: task-def + # uses: aws-actions/amazon-ecs-render-task-definition@v1 + # with: + # task-definition: ${{ env.ECS_TASK_DEFINITION }} + # container-name: ${{ env.CONTAINER_NAME }} + # image: ${{ steps.build-image.outputs.image }} + + # - name: Deploy Amazon ECS task definition + # uses: aws-actions/amazon-ecs-deploy-task-definition@v1 + # with: + # task-definition: ${{ steps.task-def.outputs.task-definition }} + # service: ${{ env.ECS_SERVICE }} + # cluster: ${{ env.ECS_CLUSTER }} + # wait-for-service-stability: true diff --git a/.github/workflows/docker-publish-key-manager.yml b/.github/workflows/docker-publish-key-manager.yml index 720ea2a..eced289 100644 --- a/.github/workflows/docker-publish-key-manager.yml +++ b/.github/workflows/docker-publish-key-manager.yml @@ -31,6 +31,12 @@ env: # github.repository as / IMAGE_NAME: ${{ github.repository }} KEY_MAN_DIR: "src/key_management" + AWS_REGION: us-east-1 + ECR_REPOSITORY: "j9l1s4z2/go-ja-holidays-key-manager" + ECS_SERVICE: holidays-key-manager-service + ECS_CLUSTER: holidays-cluster + ECS_TASK_DEFINITION: .aws/key_manager_task.json + CONTAINER_NAME: MY_CONTAINER_NAME jobs: @@ -213,3 +219,57 @@ jobs: # This step uses the identity token to provision an ephemeral certificate # against the sigstore community Fulcio instance. run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST} + + deploy: + permissions: + id-token: write + needs: test-key-manager + name: Deploy to ECR + runs-on: ubuntu-latest + environment: production + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: ${{ secrets.ASSUME_ROLE }} + aws-region: ${{ env.AWS_REGION }} + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v1 + with: + mask-password: 'true' + registry-type: public + + - name: Build, tag, and push image to Amazon ECR + id: build-image + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + IMAGE_TAG: ${{ github.sha }} + run: | + # Build a docker container and + # push it to ECR so that it can + # be deployed to ECS. + docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -f docker/key_management/Dockerfile . + docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG + echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT + + # - name: Fill in the new image ID in the Amazon ECS task definition + # id: task-def + # uses: aws-actions/amazon-ecs-render-task-definition@v1 + # with: + # task-definition: ${{ env.ECS_TASK_DEFINITION }} + # container-name: ${{ env.CONTAINER_NAME }} + # image: ${{ steps.build-image.outputs.image }} + + # - name: Deploy Amazon ECS task definition + # uses: aws-actions/amazon-ecs-deploy-task-definition@v1 + # with: + # task-definition: ${{ steps.task-def.outputs.task-definition }} + # service: ${{ env.ECS_SERVICE }} + # cluster: ${{ env.ECS_CLUSTER }} + # wait-for-service-stability: true \ No newline at end of file From 6ea4f99131e26c4b11397935216baf2901d8feaf Mon Sep 17 00:00:00 2001 From: kynmh69 Date: Sat, 30 Mar 2024 17:28:28 +0900 Subject: [PATCH 13/21] feature add create ecs service #28 --- .github/workflows/docker-publish-api.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-publish-api.yml b/.github/workflows/docker-publish-api.yml index eff9341..cfe7642 100644 --- a/.github/workflows/docker-publish-api.yml +++ b/.github/workflows/docker-publish-api.yml @@ -223,7 +223,7 @@ jobs: deploy: permissions: id-token: write - needs: test-updater + needs: test-api name: Deploy to ECR runs-on: ubuntu-latest environment: production From be9ea8d94c5abdf65c519a92bd191e2a4e85f547 Mon Sep 17 00:00:00 2001 From: kynmh69 Date: Sun, 31 Mar 2024 09:27:57 +0900 Subject: [PATCH 14/21] feature add create ecs service #28 --- .github/workflows/docker-publish-updater.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker-publish-updater.yml b/.github/workflows/docker-publish-updater.yml index ae8933c..d781aaa 100644 --- a/.github/workflows/docker-publish-updater.yml +++ b/.github/workflows/docker-publish-updater.yml @@ -36,7 +36,8 @@ env: ECS_SERVICE: holidays-updater-service ECS_CLUSTER: holidays-cluster ECS_TASK_DEFINITION: .aws/updater_task.json - CONTAINER_NAME: MY_CONTAINER_NAME + CONTAINER_NAME: holidays-updater + PLATFORM: "linux/amd64,linux/arm64,linux/x86_64" jobs: analyze: @@ -199,7 +200,7 @@ jobs: labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha cache-to: type=gha,mode=max - platforms: linux/amd64,linux/arm64,linux/x86_64 + platforms: ${{ env.PLATFORM }} # Sign the resulting Docker image digest except on PRs. # This will only write to the public Rekor transparency log when the Docker @@ -246,12 +247,14 @@ jobs: env: ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} IMAGE_TAG: ${{ github.sha }} + PLATFORM: ${{ env.PLATFORM }} run: | # Build a docker container and # push it to ECR so that it can # be deployed to ECS. - docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -f docker/updater/Dockerfile . + docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG,$ECR_REGISTRY/$ECR_REPOSITORY:latest --platform $PLATFORM -f docker/updater/Dockerfile . docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG + docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT # - name: Fill in the new image ID in the Amazon ECS task definition From 6b68b9cbff09148bd21ffb9a0010bb87fe1f526e Mon Sep 17 00:00:00 2001 From: kynmh69 Date: Sun, 31 Mar 2024 09:44:51 +0900 Subject: [PATCH 15/21] feature add create ecs service #28 --- .github/workflows/docker-publish-updater.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-publish-updater.yml b/.github/workflows/docker-publish-updater.yml index d781aaa..42b40c9 100644 --- a/.github/workflows/docker-publish-updater.yml +++ b/.github/workflows/docker-publish-updater.yml @@ -252,7 +252,7 @@ jobs: # Build a docker container and # push it to ECR so that it can # be deployed to ECS. - docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG,$ECR_REGISTRY/$ECR_REPOSITORY:latest --platform $PLATFORM -f docker/updater/Dockerfile . + docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -t $ECR_REGISTRY/$ECR_REPOSITORY:latest --platform $PLATFORM -f docker/updater/Dockerfile . docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT From 25969c02a2d5b7d95d5ab5ce6283a23f9e3f335b Mon Sep 17 00:00:00 2001 From: kynmh69 Date: Sun, 31 Mar 2024 09:55:45 +0900 Subject: [PATCH 16/21] feature add create ecs service #28 --- .github/workflows/docker-publish-updater.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker-publish-updater.yml b/.github/workflows/docker-publish-updater.yml index 42b40c9..aed4591 100644 --- a/.github/workflows/docker-publish-updater.yml +++ b/.github/workflows/docker-publish-updater.yml @@ -252,9 +252,9 @@ jobs: # Build a docker container and # push it to ECR so that it can # be deployed to ECS. - docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -t $ECR_REGISTRY/$ECR_REPOSITORY:latest --platform $PLATFORM -f docker/updater/Dockerfile . - docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG - docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest + docker buildx install + docker buildx create builder --use + docker buildx build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -t $ECR_REGISTRY/$ECR_REPOSITORY:latest --platform $PLATFORM --push -f docker/updater/Dockerfile . echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT # - name: Fill in the new image ID in the Amazon ECS task definition From 6d2ec4adcf73a72b20d92329ad5bff69aa16a233 Mon Sep 17 00:00:00 2001 From: kynmh69 Date: Sun, 31 Mar 2024 10:43:26 +0900 Subject: [PATCH 17/21] feature add create ecs service #28 --- .github/workflows/docker-publish-updater.yml | 56 ++++++++++++++------ 1 file changed, 41 insertions(+), 15 deletions(-) diff --git a/.github/workflows/docker-publish-updater.yml b/.github/workflows/docker-publish-updater.yml index aed4591..d5ef681 100644 --- a/.github/workflows/docker-publish-updater.yml +++ b/.github/workflows/docker-publish-updater.yml @@ -32,7 +32,6 @@ env: UPDATER_DIR: "src/updater" DOCKER_FILE: "docker/updater" AWS_REGION: us-east-1 - ECR_REPOSITORY: "j9l1s4z2/go-ja-holidays-updater" ECS_SERVICE: holidays-updater-service ECS_CLUSTER: holidays-cluster ECS_TASK_DEFINITION: .aws/updater_task.json @@ -228,6 +227,12 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + + # Set up BuildKit Docker container builder to be able to build + # multi-platform images and export cache + # https://github.com/docker/setup-buildx-action + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 # v3.1.0 - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v4 @@ -242,20 +247,41 @@ jobs: mask-password: 'true' registry-type: public - - name: Build, tag, and push image to Amazon ECR - id: build-image - env: - ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} - IMAGE_TAG: ${{ github.sha }} - PLATFORM: ${{ env.PLATFORM }} - run: | - # Build a docker container and - # push it to ECR so that it can - # be deployed to ECS. - docker buildx install - docker buildx create builder --use - docker buildx build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -t $ECR_REGISTRY/$ECR_REPOSITORY:latest --platform $PLATFORM --push -f docker/updater/Dockerfile . - echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT + # Extract metadata (tags, labels) for Docker + # https://github.com/docker/metadata-action + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v5 # v5.0.0 + with: + images: ${{ steps.login-ecr.outputs.registry }}/${{ env.IMAGE_NAME }}-updater + + # Build and push Docker image with Buildx (don't push on PR) + # https://github.com/docker/build-push-action + - name: Build and push Docker image + id: build-and-push + uses: docker/build-push-action@v5 + with: + context: . + file: docker/updater/Dockerfile + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + platforms: ${{ env.PLATFORM }} + + # - name: Build, tag, and push image to Amazon ECR + # id: build-image + # env: + # ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + # IMAGE_TAG: ${{ github.sha }} + # PLATFORM: ${{ env.PLATFORM }} + # run: | + # # Build a docker container and + # # push it to ECR so that it can + # # be deployed to ECS. + # docker buildx build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -t $ECR_REGISTRY/$ECR_REPOSITORY:latest --platform $PLATFORM --push -f docker/updater/Dockerfile . + # echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT # - name: Fill in the new image ID in the Amazon ECS task definition # id: task-def From 1acb0a1aab9b381f6774ce167bc404ca39a934bf Mon Sep 17 00:00:00 2001 From: kynmh69 Date: Sun, 31 Mar 2024 10:52:35 +0900 Subject: [PATCH 18/21] feature add create ecs service #28 --- .github/workflows/docker-publish-updater.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-publish-updater.yml b/.github/workflows/docker-publish-updater.yml index d5ef681..0a97a04 100644 --- a/.github/workflows/docker-publish-updater.yml +++ b/.github/workflows/docker-publish-updater.yml @@ -242,7 +242,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' registry-type: public From 1ce26dece2add31b42ce2e9186f030c97d7e4f37 Mon Sep 17 00:00:00 2001 From: kynmh69 Date: Sun, 31 Mar 2024 10:59:34 +0900 Subject: [PATCH 19/21] feature add create ecs service #28 --- .github/workflows/docker-publish-api.yml | 43 ++++++++++++------ .../workflows/docker-publish-key-manager.yml | 44 +++++++++++++------ .github/workflows/docker-publish-updater.yml | 21 ++------- 3 files changed, 64 insertions(+), 44 deletions(-) diff --git a/.github/workflows/docker-publish-api.yml b/.github/workflows/docker-publish-api.yml index cfe7642..5e67535 100644 --- a/.github/workflows/docker-publish-api.yml +++ b/.github/workflows/docker-publish-api.yml @@ -37,6 +37,7 @@ env: ECS_CLUSTER: holidays-cluster ECS_TASK_DEFINITION: .aws/api_task.json CONTAINER_NAME: MY_CONTAINER_NAME + PLATFORM: "linux/amd64,linux/arm64,linux/x86_64" jobs: @@ -232,6 +233,12 @@ jobs: - name: Checkout uses: actions/checkout@v4 + # Set up BuildKit Docker container builder to be able to build + # multi-platform images and export cache + # https://github.com/docker/setup-buildx-action + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 # v3.1.0 + - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v4 with: @@ -245,18 +252,28 @@ jobs: mask-password: 'true' registry-type: public - - name: Build, tag, and push image to Amazon ECR - id: build-image - env: - ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} - IMAGE_TAG: ${{ github.sha }} - run: | - # Build a docker container and - # push it to ECR so that it can - # be deployed to ECS. - docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -f docker/api/Dockerfile . - docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG - echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT + # Extract metadata (tags, labels) for Docker + # https://github.com/docker/metadata-action + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v5 # v5.0.0 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-api + + # Build and push Docker image with Buildx (don't push on PR) + # https://github.com/docker/build-push-action + - name: Build and push Docker image + id: build-and-push + uses: docker/build-push-action@v5 + with: + context: . + file: docker/updater/Dockerfile + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + platforms: ${{ env.PLATFORM }} # - name: Fill in the new image ID in the Amazon ECS task definition # id: task-def @@ -264,7 +281,7 @@ jobs: # with: # task-definition: ${{ env.ECS_TASK_DEFINITION }} # container-name: ${{ env.CONTAINER_NAME }} - # image: ${{ steps.build-image.outputs.image }} + # image: ${{ steps.build-and-push.outputs.image }} # - name: Deploy Amazon ECS task definition # uses: aws-actions/amazon-ecs-deploy-task-definition@v1 diff --git a/.github/workflows/docker-publish-key-manager.yml b/.github/workflows/docker-publish-key-manager.yml index eced289..6dc9b17 100644 --- a/.github/workflows/docker-publish-key-manager.yml +++ b/.github/workflows/docker-publish-key-manager.yml @@ -32,11 +32,11 @@ env: IMAGE_NAME: ${{ github.repository }} KEY_MAN_DIR: "src/key_management" AWS_REGION: us-east-1 - ECR_REPOSITORY: "j9l1s4z2/go-ja-holidays-key-manager" ECS_SERVICE: holidays-key-manager-service ECS_CLUSTER: holidays-cluster ECS_TASK_DEFINITION: .aws/key_manager_task.json CONTAINER_NAME: MY_CONTAINER_NAME + PLATFORM: "linux/amd64,linux/arm64,linux/x86_64" jobs: @@ -232,6 +232,12 @@ jobs: - name: Checkout uses: actions/checkout@v4 + # Set up BuildKit Docker container builder to be able to build + # multi-platform images and export cache + # https://github.com/docker/setup-buildx-action + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 # v3.1.0 + - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v4 with: @@ -245,18 +251,28 @@ jobs: mask-password: 'true' registry-type: public - - name: Build, tag, and push image to Amazon ECR - id: build-image - env: - ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} - IMAGE_TAG: ${{ github.sha }} - run: | - # Build a docker container and - # push it to ECR so that it can - # be deployed to ECS. - docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -f docker/key_management/Dockerfile . - docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG - echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT + # Extract metadata (tags, labels) for Docker + # https://github.com/docker/metadata-action + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v5 # v5.0.0 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-key-manager + + # Build and push Docker image with Buildx (don't push on PR) + # https://github.com/docker/build-push-action + - name: Build and push Docker image + id: build-and-push + uses: docker/build-push-action@v5 + with: + context: . + file: docker/updater/Dockerfile + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + platforms: ${{ env.PLATFORM }} # - name: Fill in the new image ID in the Amazon ECS task definition # id: task-def @@ -264,7 +280,7 @@ jobs: # with: # task-definition: ${{ env.ECS_TASK_DEFINITION }} # container-name: ${{ env.CONTAINER_NAME }} - # image: ${{ steps.build-image.outputs.image }} + # image: ${{ steps.build-and-push.outputs.image }} # - name: Deploy Amazon ECS task definition # uses: aws-actions/amazon-ecs-deploy-task-definition@v1 diff --git a/.github/workflows/docker-publish-updater.yml b/.github/workflows/docker-publish-updater.yml index 0a97a04..4a9599c 100644 --- a/.github/workflows/docker-publish-updater.yml +++ b/.github/workflows/docker-publish-updater.yml @@ -229,8 +229,8 @@ jobs: uses: actions/checkout@v4 # Set up BuildKit Docker container builder to be able to build - # multi-platform images and export cache - # https://github.com/docker/setup-buildx-action + # multi-platform images and export cache + # https://github.com/docker/setup-buildx-action - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 # v3.1.0 @@ -256,7 +256,7 @@ jobs: images: ${{ steps.login-ecr.outputs.registry }}/${{ env.IMAGE_NAME }}-updater # Build and push Docker image with Buildx (don't push on PR) - # https://github.com/docker/build-push-action + # https://github.com/docker/build-push-action - name: Build and push Docker image id: build-and-push uses: docker/build-push-action@v5 @@ -270,26 +270,13 @@ jobs: cache-to: type=gha,mode=max platforms: ${{ env.PLATFORM }} - # - name: Build, tag, and push image to Amazon ECR - # id: build-image - # env: - # ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} - # IMAGE_TAG: ${{ github.sha }} - # PLATFORM: ${{ env.PLATFORM }} - # run: | - # # Build a docker container and - # # push it to ECR so that it can - # # be deployed to ECS. - # docker buildx build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -t $ECR_REGISTRY/$ECR_REPOSITORY:latest --platform $PLATFORM --push -f docker/updater/Dockerfile . - # echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT - # - name: Fill in the new image ID in the Amazon ECS task definition # id: task-def # uses: aws-actions/amazon-ecs-render-task-definition@v1 # with: # task-definition: ${{ env.ECS_TASK_DEFINITION }} # container-name: ${{ env.CONTAINER_NAME }} - # image: ${{ steps.build-image.outputs.image }} + # image: ${{ steps.build-and-push.outputs.image }} # - name: Deploy Amazon ECS task definition # uses: aws-actions/amazon-ecs-deploy-task-definition@v1 From f4d4639db838a5095ceb601a20158d9cf6771d81 Mon Sep 17 00:00:00 2001 From: kynmh69 Date: Sun, 31 Mar 2024 11:07:15 +0900 Subject: [PATCH 20/21] feature add create ecs service #28 --- .github/workflows/docker-publish-api.yml | 8 ++++---- .github/workflows/docker-publish-key-manager.yml | 7 ++++--- .github/workflows/docker-publish-updater.yml | 6 +++--- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.github/workflows/docker-publish-api.yml b/.github/workflows/docker-publish-api.yml index 5e67535..33ba5fd 100644 --- a/.github/workflows/docker-publish-api.yml +++ b/.github/workflows/docker-publish-api.yml @@ -32,12 +32,12 @@ env: IMAGE_NAME: ${{ github.repository }} API_DIR: "src/api" AWS_REGION: us-east-1 - ECR_REPOSITORY: "j9l1s4z2/go-ja-holidays-api" ECS_SERVICE: holidays-api-service ECS_CLUSTER: holidays-cluster ECS_TASK_DEFINITION: .aws/api_task.json - CONTAINER_NAME: MY_CONTAINER_NAME + CONTAINER_NAME: holidays-api PLATFORM: "linux/amd64,linux/arm64,linux/x86_64" + DOCKER_FILEPATH: "docker/api/Dockerfile" jobs: @@ -198,7 +198,7 @@ jobs: uses: docker/build-push-action@v5 with: context: . - file: docker/api/Dockerfile + file: ${{ env.DOCKER_FILEPATH }} push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} @@ -267,7 +267,7 @@ jobs: uses: docker/build-push-action@v5 with: context: . - file: docker/updater/Dockerfile + file: ${{ env.DOCKER_FILEPATH }} push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/docker-publish-key-manager.yml b/.github/workflows/docker-publish-key-manager.yml index 6dc9b17..14c0a7c 100644 --- a/.github/workflows/docker-publish-key-manager.yml +++ b/.github/workflows/docker-publish-key-manager.yml @@ -35,8 +35,9 @@ env: ECS_SERVICE: holidays-key-manager-service ECS_CLUSTER: holidays-cluster ECS_TASK_DEFINITION: .aws/key_manager_task.json - CONTAINER_NAME: MY_CONTAINER_NAME + CONTAINER_NAME: holidays-key-manager PLATFORM: "linux/amd64,linux/arm64,linux/x86_64" + DOCKER_FILEPATH: "docker/key_management/Dockerfile" jobs: @@ -197,7 +198,7 @@ jobs: uses: docker/build-push-action@v5 with: context: . - file: docker/api/Dockerfile + file: ${{ env.DOCKER_FILEPATH }} push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} @@ -266,7 +267,7 @@ jobs: uses: docker/build-push-action@v5 with: context: . - file: docker/updater/Dockerfile + file: ${{ env.DOCKER_FILEPATH }} push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/docker-publish-updater.yml b/.github/workflows/docker-publish-updater.yml index 4a9599c..b21aeb2 100644 --- a/.github/workflows/docker-publish-updater.yml +++ b/.github/workflows/docker-publish-updater.yml @@ -30,13 +30,13 @@ env: # github.repository as / IMAGE_NAME: ${{ github.repository }} UPDATER_DIR: "src/updater" - DOCKER_FILE: "docker/updater" AWS_REGION: us-east-1 ECS_SERVICE: holidays-updater-service ECS_CLUSTER: holidays-cluster ECS_TASK_DEFINITION: .aws/updater_task.json CONTAINER_NAME: holidays-updater PLATFORM: "linux/amd64,linux/arm64,linux/x86_64" + DOCKER_FILEPATH: "docker/updater/Dockerfile" jobs: analyze: @@ -193,7 +193,7 @@ jobs: uses: docker/build-push-action@v5 with: context: . - file: docker/updater/Dockerfile + file: ${{ env.DOCKER_FILEPATH }} push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} @@ -262,7 +262,7 @@ jobs: uses: docker/build-push-action@v5 with: context: . - file: docker/updater/Dockerfile + file: ${{ env.DOCKER_FILEPATH }} push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} From abe1421fd761c5388e466b77d45ade2f8003b389 Mon Sep 17 00:00:00 2001 From: kynmh69 Date: Sun, 31 Mar 2024 11:14:50 +0900 Subject: [PATCH 21/21] feature add create ecs service #28 --- .github/workflows/docker-publish-api.yml | 2 +- .github/workflows/docker-publish-key-manager.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-publish-api.yml b/.github/workflows/docker-publish-api.yml index 33ba5fd..2b4a628 100644 --- a/.github/workflows/docker-publish-api.yml +++ b/.github/workflows/docker-publish-api.yml @@ -258,7 +258,7 @@ jobs: id: meta uses: docker/metadata-action@v5 # v5.0.0 with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-api + images: ${{ steps.login-ecr.outputs.registry }}/${{ env.IMAGE_NAME }}-api # Build and push Docker image with Buildx (don't push on PR) # https://github.com/docker/build-push-action diff --git a/.github/workflows/docker-publish-key-manager.yml b/.github/workflows/docker-publish-key-manager.yml index 14c0a7c..ce36cd0 100644 --- a/.github/workflows/docker-publish-key-manager.yml +++ b/.github/workflows/docker-publish-key-manager.yml @@ -258,7 +258,7 @@ jobs: id: meta uses: docker/metadata-action@v5 # v5.0.0 with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-key-manager + images: ${{ steps.login-ecr.outputs.registry }}/${{ env.IMAGE_NAME }}-key-manager # Build and push Docker image with Buildx (don't push on PR) # https://github.com/docker/build-push-action