|
| 1 | +name: deploy-native-template |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + target_branch: |
| 7 | + required: false |
| 8 | + type: string |
| 9 | + default: '' |
| 10 | + ecr_repository: |
| 11 | + required: true |
| 12 | + type: string |
| 13 | + dockerfile: |
| 14 | + required: true |
| 15 | + type: string |
| 16 | + description: 'Dockerfile path (e.g., api/Dockerfile-native)' |
| 17 | + secrets: |
| 18 | + AWS_ACCESS_KEY_ID: |
| 19 | + required: true |
| 20 | + AWS_SECRET_ACCESS_KEY: |
| 21 | + required: true |
| 22 | + |
| 23 | +jobs: |
| 24 | + deploy: |
| 25 | + name: Deploy Native |
| 26 | + runs-on: ubuntu-24.04-arm |
| 27 | + |
| 28 | + env: |
| 29 | + IMAGE_TAG: ${{ github.run_number }} |
| 30 | + BUILD_NUMBER: ${{ github.run_number }} |
| 31 | + ECR_REGISTRY: 405906814034.dkr.ecr.ap-northeast-2.amazonaws.com |
| 32 | + ECR_REPOSITORY: ${{ inputs.ecr_repository }} |
| 33 | + |
| 34 | + steps: |
| 35 | + - name: Checkout |
| 36 | + uses: actions/checkout@v4 |
| 37 | + with: |
| 38 | + ref: ${{ inputs.target_branch || github.ref }} |
| 39 | + |
| 40 | + - name: Configure AWS credentials |
| 41 | + uses: aws-actions/configure-aws-credentials@v4 |
| 42 | + with: |
| 43 | + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 44 | + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 45 | + aws-region: ap-northeast-2 |
| 46 | + |
| 47 | + - name: Login to ECR |
| 48 | + id: login-ecr |
| 49 | + uses: aws-actions/amazon-ecr-login@v2 |
| 50 | + |
| 51 | + - name: Get and save Auth Token for CodeArtifact |
| 52 | + id: get-save-codeartifact-auth-token |
| 53 | + run: | |
| 54 | + aws codeartifact get-authorization-token \ |
| 55 | + --domain wafflestudio \ |
| 56 | + --domain-owner 405906814034 \ |
| 57 | + --query authorizationToken \ |
| 58 | + --region ap-northeast-1 \ |
| 59 | + --output text > .codeartifact_token |
| 60 | +
|
| 61 | + - name: Docker build, tag, and push image to ECR |
| 62 | + id: build-push-image |
| 63 | + run: | |
| 64 | + docker build \ |
| 65 | + --secret id=codeartifact_token,src=./.codeartifact_token \ |
| 66 | + -f ${{ inputs.dockerfile }} \ |
| 67 | + -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG \ |
| 68 | + . \ |
| 69 | + --platform linux/arm64 |
| 70 | + docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG |
| 71 | + echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT |
| 72 | +
|
0 commit comments