Skip to content

Commit

Permalink
Merge pull request #309 from Marukome0743/pr309
Browse files Browse the repository at this point in the history
♻️ci: separate docker ci jobs
  • Loading branch information
Marukome0743 authored Apr 24, 2024
2 parents cb7f961 + e527d65 commit 7221a99
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/auto-assign.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
steps:
- name: Choose an Assignee
run: echo ASSIGNEE=$(shuf -e HaradaTakayuki kazutan1230 Marukome0743 tanePON -n 1) >> $GITHUB_ENV

- name: Assign Issue
if: github.event_name == 'issues' && toJSON(github.event.issue.assignees) == '[]'
run: gh issue edit ${{ github.event.issue.number }} --add-assignee ${{ env.ASSIGNEE }} --repo ${{ github.repository }}
Expand Down
59 changes: 35 additions & 24 deletions .github/workflows/push-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,6 @@ jobs:
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Configure AWS credentials
if: fromJSON(env.IS_PUSH)
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}

- name: Login to Amazon ECR
if: fromJSON(env.IS_PUSH)
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2

- name: Docker Meta
id: meta
uses: docker/metadata-action@v5
Expand Down Expand Up @@ -109,17 +96,6 @@ jobs:
cache-to: type=gha,mode=max
provenance: false

- name: Build and Push Image to Amazon ECR
if: fromJSON(env.IS_PUSH)
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
IMAGE_TAG: ${{ github.sha }}
run: |
docker build --platform linux/arm64 -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
aws lambda update-function-code --function-name $LAMBDA_FUNCTION_NAME \
--architectures arm64 --image-uri $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
- name: Docker Scout
if: github.repository_owner == env.REPOSITORY_OWNER && github.event_name == 'pull_request_target'
uses: docker/scout-action@v1
Expand All @@ -128,3 +104,38 @@ jobs:
image: ${{ env.REPOSITORY }}:${{ steps.meta.outputs.version }}
to: ${{ env.GHCR_REGISTRY }}/${{ env.GHCR_REPOSITORY }}:canary
only-severities: critical,high

lambda:
runs-on: ubuntu-latest
if: inputs.push || github.event_name == 'push' && github.repository_owner == 'openup-labtakizawa' && github.ref_name == 'main'

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2

- name: Build and Push Image to Amazon ECR
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
IMAGE_TAG: ${{ github.sha }}
run: |
docker build --platform linux/arm64 -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
aws lambda update-function-code --function-name $LAMBDA_FUNCTION_NAME \
--architectures arm64 --image-uri $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG

0 comments on commit 7221a99

Please sign in to comment.