From 46178248ad016976fecb2b098bfc9ff065d3886d Mon Sep 17 00:00:00 2001 From: meehawk Date: Fri, 21 May 2021 08:15:02 +0200 Subject: [PATCH 1/3] rfac: split actions across multiple jobs --- .github/workflows/ci.yml | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a2bf735..21e029d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,20 +6,25 @@ on: pull_request: branches: [main] +env: + AWS_DEFAULT_REGION: us-east-1 + AWS_BACKUP_REGION: eu-central-1 + CLOUDFLARE_ACCOUNT_ID: 895762025d37fc687ecd72d7cc80204a + CLOUDFLARE_ZONE_ID: c192cf8ac042c681023493c52edd44c8 + jobs: - build: + setup: runs-on: ubuntu-latest-xl - env: - AWS_DEFAULT_REGION: us-east-1 - AWS_BACKUP_REGION: eu-central-1 - CLOUDFLARE_ACCOUNT_ID: 895762025d37fc687ecd72d7cc80204a - CLOUDFLARE_ZONE_ID: c192cf8ac042c681023493c52edd44c8 steps: - name: Setup Deno environment uses: denolib/setup-deno@v2.3.0 with: deno-version: v1.6.2 + test: + runs-on: ubuntu-latest-xl + needs: setup + steps: - uses: actions/checkout@v2 - name: Format @@ -36,6 +41,10 @@ jobs: - name: Test run: make test + build: + needs: test + runs-on: ubuntu-latest-xl + steps: - name: Validate run: | terraform init -backend=false @@ -43,7 +52,7 @@ jobs: working-directory: terraform - name: Push container to ECR (prod) - if: github.ref == 'refs/heads/main' + if: github.ref == 'refs/head/main' run: | ECR_ID=$(aws sts get-caller-identity --query Account --output text).dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com IMAGE_ID=$ECR_ID/deno_registry2:$GITHUB_RUN_ID @@ -81,7 +90,11 @@ jobs: AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} working-directory: terraform - + + deploy: + needs: build + runs-on: ubuntu-lastest-xl + steps: - name: Deploy infrastructure (prod) if: github.ref == 'refs/heads/main' run: terraform apply -parallelism=3 plan.tfplan From 97ae39c3563ab61ea05cc11d9f5a90406ae10537 Mon Sep 17 00:00:00 2001 From: meehawk Date: Fri, 21 May 2021 08:20:57 +0200 Subject: [PATCH 2/3] fix: typo in 'heads' --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 21e029d..fdb5b40 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,8 +22,8 @@ jobs: deno-version: v1.6.2 test: - runs-on: ubuntu-latest-xl needs: setup + runs-on: ubuntu-latest-xl steps: - uses: actions/checkout@v2 @@ -52,7 +52,7 @@ jobs: working-directory: terraform - name: Push container to ECR (prod) - if: github.ref == 'refs/head/main' + if: github.ref == 'refs/heads/main' run: | ECR_ID=$(aws sts get-caller-identity --query Account --output text).dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com IMAGE_ID=$ECR_ID/deno_registry2:$GITHUB_RUN_ID From a41ad57bdc946a6980fb1cef8d7a3fd774136e5e Mon Sep 17 00:00:00 2001 From: meehawk Date: Fri, 21 May 2021 15:51:17 +0200 Subject: [PATCH 3/3] patch: add setup-deno step to every job --- .github/workflows/ci.yml | 43 +++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fdb5b40..6620a81 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,8 @@ env: CLOUDFLARE_ZONE_ID: c192cf8ac042c681023493c52edd44c8 jobs: - setup: + + test: runs-on: ubuntu-latest-xl steps: - name: Setup Deno environment @@ -21,10 +22,6 @@ jobs: with: deno-version: v1.6.2 - test: - needs: setup - runs-on: ubuntu-latest-xl - steps: - uses: actions/checkout@v2 - name: Format @@ -35,9 +32,6 @@ jobs: - name: Lint run: deno lint --unstable - - name: Docker build - run: make build - - name: Test run: make test @@ -45,11 +39,13 @@ jobs: needs: test runs-on: ubuntu-latest-xl steps: - - name: Validate - run: | - terraform init -backend=false - terraform validate - working-directory: terraform + - name: Setup Deno environment + uses: denolib/setup-deno@v2.3.0 + with: + deno-version: v1.6.2 + + - name: Docker build + run: make build - name: Push container to ECR (prod) if: github.ref == 'refs/heads/main' @@ -62,6 +58,21 @@ jobs: env: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + + deploy: + needs: build + runs-on: ubuntu-lastest-xl + steps: + - name: Setup Deno environment + uses: denolib/setup-deno@v2.3.0 + with: + deno-version: v1.6.2 + + - name: Validate + run: | + terraform init -backend=false + terraform validate + working-directory: terraform - name: Create terraform plan (prod) if: github.ref == 'refs/heads/main' @@ -90,11 +101,7 @@ jobs: AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} working-directory: terraform - - deploy: - needs: build - runs-on: ubuntu-lastest-xl - steps: + - name: Deploy infrastructure (prod) if: github.ref == 'refs/heads/main' run: terraform apply -parallelism=3 plan.tfplan