diff --git a/.github/workflows/docker-deploy.yml b/.github/workflows/docker-deploy.yml index 242bcda548..236bcba96a 100644 --- a/.github/workflows/docker-deploy.yml +++ b/.github/workflows/docker-deploy.yml @@ -1,8 +1,14 @@ -name: Deploy Docker +name: DrawIO Docker Build on: [push] env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + REPOSITORY_NAME: ${{ github.event.repository.name }} + ECR_REPOSITORY: codio/${{ github.event.repository.name }} + +permissions: + contents: read + id-token: write jobs: build-docker: @@ -10,73 +16,52 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v4 - - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v4 - with: - aws-access-key-id: ${{ secrets.ECR_UPLOADER_KEY }} - aws-secret-access-key: ${{ secrets.ECR_UPLOADER_SECRET }} - aws-region: us-east-1 + uses: actions/checkout@v5 - name: Get Current Branch id: get-branch uses: codio/get-branch-name-github-action@v1 + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@main + with: + aws-region: us-east-1 + role-to-assume: arn:aws:iam::878986216776:role/Github/GithubECRUploadRole_${{ env.REPOSITORY_NAME }} + role-session-name: GithubAction + - name: Login to Amazon ECR id: login-ecr uses: aws-actions/amazon-ecr-login@v2 - - name: app Docker build - run: docker build -t tmp_app_img --file ./docker-codio/Dockerfile . + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 - - name: push app image to Amazon ECR - env: - ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} - ECR_REPOSITORY: codio/drawio - IMAGE_TAG: ${{ github.sha }} - BRANCH: ${{ steps.get-branch.outputs.branch }} + - name: Create and use a new builder instance run: | - docker tag tmp_app_img $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG - docker tag tmp_app_img $ECR_REGISTRY/$ECR_REPOSITORY:$BRANCH - docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG - docker push $ECR_REGISTRY/$ECR_REPOSITORY:$BRANCH + docker buildx create --name ga-builder --use - - name: push app dev version - env: - ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} - ECR_REPOSITORY: codio/drawio - run: | - docker tag tmp_app_img $ECR_REGISTRY/$ECR_REPOSITORY:dev - docker push $ECR_REGISTRY/$ECR_REPOSITORY:dev - if: ${{ steps.get-branch.outputs.branch == 'dev' }} + - name: push image to Amazon ECR + uses: docker/build-push-action@v5 + timeout-minutes: 20 + with: + context: . + file: ./docker-codio/Dockerfile + push: true + tags: | + ${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPOSITORY }}:${{ github.sha }} + ${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPOSITORY }}:${{ steps.get-branch.outputs.branch }} + builder: ga-builder + cache-from: type=registry,ref=${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPOSITORY }}:cache + cache-to: type=registry,mode=max,image-manifest=true,oci-mediatypes=true,ref=${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPOSITORY }}:cache - name: Logout of Amazon ECR if: always() run: docker logout ${{ steps.login-ecr.outputs.registry }} - name: Slack - uses: 8398a7/action-slack@v3 - with: - status: custom - custom_payload: | - { - attachments: [{ - text: " for ${{ github.repository }} by ${{ github.actor }} has ${{ job.status }} on branch ${{ github.ref_name }}", - color: "good" - }] - } - if: success() - - - name: Slack - uses: 8398a7/action-slack@v3 + uses: codio/codio-slack-action@master with: - status: custom - custom_payload: | - { - attachments: [{ - text: " for ${{ github.repository }} by ${{ github.actor }} has ${{ job.status }} on branch ${{ github.ref_name }}", - color: "#FF0000" - }] - } - if: failure() + slack_hook_url: ${{ secrets.SLACK_WEBHOOK_URL }} + message: " for ${{ github.repository }} by ${{ github.actor }} has ${{ job.status }} on branch ${{ github.ref_name }}" + success: ${{ job.status }} + if: always() diff --git a/.github/workflows/war.yml b/.github/workflows/war.yml index 898f0dc4e3..30ee9f4000 100644 --- a/.github/workflows/war.yml +++ b/.github/workflows/war.yml @@ -14,9 +14,9 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v5 - name: Set up JDK 1.8 - uses: actions/setup-java@v3 + uses: actions/setup-java@v5 with: distribution: 'zulu' java-version: '8'