From c695926be012f9e21acbf55bb8340db085564515 Mon Sep 17 00:00:00 2001 From: Michael Della Bitta Date: Tue, 31 Dec 2024 11:23:38 -0500 Subject: [PATCH 1/2] added staging ecr action --- .github/workflows/ecr-staging.yml | 76 +++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 .github/workflows/ecr-staging.yml diff --git a/.github/workflows/ecr-staging.yml b/.github/workflows/ecr-staging.yml new file mode 100644 index 0000000..152f5cb --- /dev/null +++ b/.github/workflows/ecr-staging.yml @@ -0,0 +1,76 @@ +name: push to ecr + +on: + workflow_dispatch: + +env: + ECR_REPOSITORY: "thumbnail-api-staging" + +jobs: + ecr: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf + with: + image: tonistiigi/binfmt:latest + platforms: arm64,arm + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5 + + - uses: actions/setup-node@v4 + with: + node-version-file: '.nvmrc' + + - run: npm ci + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: us-east-1 + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@062b18b96a7aff071d4dc91bc00c4c1a7945b076 + + - name: Upload sourcemap to Sentry + env: + SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} + run: | + npm ci + npm install tsc -g + npm run build + npm run sentry:sourcemaps + shell: bash + + # Get branch names for ECR tagging + - name: Get branch name (merge) + if: github.event_name != 'pull_request' + shell: bash + run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/} | tr / -)" >> $GITHUB_ENV + + - name: Get branch name (pull request) + if: github.event_name == 'pull_request' + shell: bash + run: echo "BRANCH_NAME=$(echo ${GITHUB_HEAD_REF} | tr / -)" >> $GITHUB_ENV + + # Push to ECR + - name: Build, tag, and push image to Amazon ECR + id: build-image + env: + IMAGE_TAG: ${{ github.sha }} + BRANCH_NAME: ${{ env.BRANCH_NAME }} + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + run: | + docker buildx build \ + -t $ECR_REGISTRY/$ECR_REPOSITORY:latest \ + -t $ECR_REGISTRY/$ECR_REPOSITORY:$BRANCH_NAME \ + -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG \ + --platform linux/amd64,linux/arm64 . \ + --push \ No newline at end of file From 8973fdc9fd97dc9d2a3574571a57ff36d802acb3 Mon Sep 17 00:00:00 2001 From: Michael Della Bitta Date: Tue, 31 Dec 2024 11:29:31 -0500 Subject: [PATCH 2/2] renamed ecr actions to distinguish in ui --- .github/workflows/ecr-staging.yml | 2 +- .github/workflows/ecr.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ecr-staging.yml b/.github/workflows/ecr-staging.yml index 152f5cb..4ca0223 100644 --- a/.github/workflows/ecr-staging.yml +++ b/.github/workflows/ecr-staging.yml @@ -1,4 +1,4 @@ -name: push to ecr +name: "push to ecr: staging" on: workflow_dispatch: diff --git a/.github/workflows/ecr.yml b/.github/workflows/ecr.yml index aee31c5..3097eb7 100644 --- a/.github/workflows/ecr.yml +++ b/.github/workflows/ecr.yml @@ -1,4 +1,4 @@ -name: push to ecr +name: "push to ecr: production" on: workflow_dispatch: