From 286c33bdcb9946606e04d969441bd6d5ef70e6f0 Mon Sep 17 00:00:00 2001 From: Diego Cohen Date: Mon, 9 Sep 2024 11:24:47 -0400 Subject: [PATCH] Initialize deploy_production.yml --- .github/workflows/ci.yml | 4 +-- .github/workflows/deploy_production.yml | 46 +++++++++++++++++++++++++ .github/workflows/testing.yml | 6 ++-- 3 files changed, 51 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/deploy_production.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 943a55bc8..e123d90a6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Use Node.js 20.x - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: 20 - name: Cache and install node modules @@ -33,7 +33,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Use Node.js 20.x - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: 20 - name: Cache and install node modules diff --git a/.github/workflows/deploy_production.yml b/.github/workflows/deploy_production.yml new file mode 100644 index 000000000..1106cbcac --- /dev/null +++ b/.github/workflows/deploy_production.yml @@ -0,0 +1,46 @@ +# Deploys to research-catalog-production +name: deploy production + +on: + push: + branches: + - production + +permissions: + id-token: write + contents: read + +env: + AWS_DEFAULT_REGION: us-east-1 + LOCAL_TAG_NAME: research-catalog:${{ github.ref_name }}-${{ github.run_number }} + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v4 + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: arn:aws:iam::946183545209:role/GithubActionsDeployerRole + aws-region: us-east-1 + + - name: Log in to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v1 + + - name: Build and push Docker image to Amazon ECR + env: + APP_ENV: production + NEW_RELIC_LICENSE_KEY: ${{ secrets.NEW_RELIC_LICENSE_KEY }} + ECR_URL: 946183545209.dkr.ecr.us-east-1.amazonaws.com/research-catalog + run: | + docker build --build-arg APP_ENV=$APP_ENV --build-arg NEW_RELIC_LICENSE_KEY=$NEW_RELIC_LICENSE_KEY --tag $LOCAL_TAG_NAME . + docker tag $LOCAL_TAG_NAME $ECR_URL + docker push $ECR_URL + + - name: Update ECS service + run: | + aws ecs update-service --cluster research-catalog-production --service research-catalog-production --force-new-deployment diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index b706a49df..baea7a1eb 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -8,12 +8,12 @@ jobs: strategy: matrix: - node-version: [18.x] + node-version: [20.x] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} - name: npm install