diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index e22278c..0000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,73 +0,0 @@ -name: Publish Docker Image - -on: - release: - types: [published] - -env: - IMAGE_NAME: ${{ github.repository }} - ECS_TASK_DEFINITION: task-definition.json - ECS_CONTAINER_NAME: frontend - ECS_CLUSTER: hanseithion-cluster - ECS_SERVICE: hanseithion-frontend-services - -jobs: - push_to_registry: - name: Push Docker image to multiple registries - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - - steps: - - uses: actions/checkout@v3 - - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v1 - with: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }} - aws-region: ap-northeast-2 - - - name: Log in to Amazon ECR - id: ecr - uses: aws-actions/amazon-ecr-login@v1 - - - name: Log in to the Github Container Registry - uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 - with: - images: | - ${{ steps.ecr.outputs.registry }}/${{ env.IMAGE_NAME }} - ghcr.io/${{ env.IMAGE_NAME }} - - - name: Build and push Docker image - uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 - with: - context: . - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - - - 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.ECS_CONTAINER_NAME }} - image: ${{ steps.ecr.outputs.registry }}/${{ env.IMAGE_NAME }}:${{ github.event.release.tag_name }} - - - name: Deploy Amazon ECS task definition - uses: aws-actions/amazon-ecs-deploy-task-definition@v1 - with: - task-definition: ${{ steps.task-def.outputs.task-definition }} - cluster: ${{ env.ECS_CLUSTER }} - service: ${{ env.ECS_SERVICE }} - wait-for-service-stability: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..7b8cf11 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,50 @@ +name: Release + +on: + release: + types: [published] + +env: + IMAGE_NAME: ${{ github.repository }} + +jobs: + push_to_registry: + name: Push Docker image to multiple registries + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - uses: actions/checkout@v3 + + - name: Log in to the Github Container Registry + uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + with: + images: | + ghcr.io/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + deploy_to_amplify: + name: Request Amplify Deploy + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Send request to Amplify deploy webhook + run: curl -X POST -d {} ${{ secrets.AMPLIFY_DEPLOY_WEBHOOK }} -H "Content-Type:application/json"