diff --git a/.github/workflows/_build.yml b/.github/workflows/_build.yml index 2995a0a..8a09577 100755 --- a/.github/workflows/_build.yml +++ b/.github/workflows/_build.yml @@ -8,12 +8,6 @@ on: ENV_FILE: required: true type: string - REPOSITORY: - required: true - type: string - BRANCH: - required: true - type: string GIT_SHA: required: true type: string @@ -24,7 +18,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set Up Ruby uses: ruby/setup-ruby@v1 @@ -32,7 +26,7 @@ jobs: ruby-version: '2.7' - name: Install Node - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: '14' diff --git a/.github/workflows/_deploy.yml b/.github/workflows/_deploy.yml index ff43377..9729a66 100755 --- a/.github/workflows/_deploy.yml +++ b/.github/workflows/_deploy.yml @@ -8,12 +8,6 @@ on: ENV_FILE: required: true type: string - REPOSITORY: - required: true - type: string - BRANCH: - required: true - type: string GIT_SHA: required: true type: string @@ -38,28 +32,19 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 - - - name: Install Node - uses: actions/setup-node@v3 - with: - node-version: '14' + uses: actions/checkout@v4 - name: Get cached build - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: build key: assets-build-${{ inputs.GIT_SHA }}-${{ inputs.RACK_ENV }} restore-keys: | assets-build-${{ inputs.GIT_SHA }}-${{ inputs.RACK_ENV }} - # It is important that delete-removed = false for now. - - name: Deploy Build - uses: reggionick/s3-deploy@master - with: - folder: build - bucket: ${{ secrets.S3_BUCKET }} - bucket-region: ${{ secrets.S3_REGION }} - dist-id: ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }} - invalidation: / - delete-removed: false + # It is important that we do NOT use --delete (matches previous delete-removed: false) + - name: Sync build to S3 + run: aws s3 sync build s3://${{ secrets.S3_BUCKET }} --region ${{ secrets.S3_REGION }} + + - name: Invalidate CloudFront + run: aws cloudfront create-invalidation --distribution-id ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*" diff --git a/.github/workflows/branch_to_staging.yml b/.github/workflows/branch_to_staging.yml index 0d1f1a7..7d92f9d 100755 --- a/.github/workflows/branch_to_staging.yml +++ b/.github/workflows/branch_to_staging.yml @@ -1,81 +1,22 @@ name: Build/Deploy Branch to Staging on: workflow_dispatch: - -env: - RACK_ENV: stage - ENV_FILE: .env.stage jobs: - vars: - runs-on: ubuntu-latest - outputs: - RACK_ENV: ${{ steps.extract_variables.outputs.RACK_ENV }} - ENV_FILE: ${{ steps.extract_variables.outputs.ENV_FILE }} - REPOSITORY: ${{ steps.extract_variables.outputs.REPOSITORY }} - BRANCH: ${{ steps.extract_variables.outputs.BRANCH }} - TAG: ${{ steps.extract_variables.outputs.TAG }} - GIT_SHA: ${{ steps.extract_variables.outputs.GIT_SHA }} - GIT_SHA_SHORT: ${{ steps.extract_variables.outputs.GIT_SHA_SHORT }} - LATEST_RELEASE: ${{ steps.extract_variables.outputs.LATEST_RELEASE }} - SITE_URL: ${{ steps.extract_variables.outputs.SITE_URL }} - SITE_NAME: ${{ steps.extract_variables.outputs.SITE_NAME }} - steps: - - name: Git checkout - uses: actions/checkout@v3 - - name: Get latest release tag - uses: oprypin/find-latest-tag@v1 - with: - repository: ${{ github.repository }} - releases-only: true - id: octokit - - name: GET .env - run: | - cp ${{ env.ENV_FILE }} .env - - name: Dotenv action - uses: falti/dotenv-action@v1.0.4 - id: dotenv - - name: Extract variables - shell: bash - run: | - echo "RACK_ENV=${{ env.RACK_ENV }}" >> $GITHUB_OUTPUT - echo "ENV_FILE=${{ env.ENV_FILE }}" >> $GITHUB_OUTPUT - echo "REPOSITORY=${{ github.repository }}" >> $GITHUB_OUTPUT - echo "BRANCH=${{ github.ref_name }}" >> $GITHUB_OUTPUT - echo "TAG=${{ github.ref_name }}" >> $GITHUB_OUTPUT - echo "GIT_SHA=${{ github.sha }}" >> $GITHUB_OUTPUT - echo "GIT_SHA_SHORT=$( git rev-parse --short ${{ github.sha }} )" >> $GITHUB_OUTPUT - echo "LATEST_RELEASE=${{ steps.octokit.outputs.tag }}" >> $GITHUB_OUTPUT - echo "SITE_NAME=${{ steps.dotenv.outputs.SITE_NAME }}" >> $GITHUB_OUTPUT - echo "SITE_URL=${{ steps.dotenv.outputs.SITE_URL }}" >> $GITHUB_OUTPUT - id: extract_variables - - name: Print state - run: | - echo "RACK_ENV = ${{ steps.extract_variables.outputs.RACK_ENV }}" - echo "ENV_FILE = ${{ steps.extract_variables.outputs.ENV_FILE }}" - echo "REPOSITORY = ${{ steps.extract_variables.outputs.REPOSITORY }}" - echo "BRANCH = ${{ steps.extract_variables.outputs.BRANCH }}" - echo "GIT_SHA = ${{ steps.extract_variables.outputs.GIT_SHA }}" - build: - needs: [vars] uses: ./.github/workflows/_build.yml with: - RACK_ENV: ${{ needs.vars.outputs.RACK_ENV }} - ENV_FILE: ${{ needs.vars.outputs.ENV_FILE }} - REPOSITORY: ${{ needs.vars.outputs.REPOSITORY }} - BRANCH: ${{ needs.vars.outputs.BRANCH }} - GIT_SHA: ${{ needs.vars.outputs.GIT_SHA }} - + RACK_ENV: stage + ENV_FILE: .env.stage + GIT_SHA: ${{ github.sha }} + deploy: - needs: [vars, build] + needs: [build] uses: ./.github/workflows/_deploy.yml with: - RACK_ENV: ${{ needs.vars.outputs.RACK_ENV }} - ENV_FILE: ${{ needs.vars.outputs.ENV_FILE }} - REPOSITORY: ${{ needs.vars.outputs.REPOSITORY }} - BRANCH: ${{ needs.vars.outputs.BRANCH }} - GIT_SHA: ${{ needs.vars.outputs.GIT_SHA }} + RACK_ENV: stage + ENV_FILE: .env.stage + GIT_SHA: ${{ github.sha }} secrets: S3_BUCKET: ${{ secrets.STAGE_S3_BUCKET }} S3_REGION: ${{ secrets.STAGE_S3_BUCKET_REGION }} diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 25563bb..4341000 100755 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -3,81 +3,22 @@ on: push: branches: - "master" - -env: - RACK_ENV: stage - ENV_FILE: .env.stage jobs: - vars: - runs-on: ubuntu-latest - outputs: - RACK_ENV: ${{ steps.extract_variables.outputs.RACK_ENV }} - ENV_FILE: ${{ steps.extract_variables.outputs.ENV_FILE }} - REPOSITORY: ${{ steps.extract_variables.outputs.REPOSITORY }} - BRANCH: ${{ steps.extract_variables.outputs.BRANCH }} - TAG: ${{ steps.extract_variables.outputs.TAG }} - GIT_SHA: ${{ steps.extract_variables.outputs.GIT_SHA }} - GIT_SHA_SHORT: ${{ steps.extract_variables.outputs.GIT_SHA_SHORT }} - LATEST_RELEASE: ${{ steps.extract_variables.outputs.LATEST_RELEASE }} - SITE_URL: ${{ steps.extract_variables.outputs.SITE_URL }} - SITE_NAME: ${{ steps.extract_variables.outputs.SITE_NAME }} - steps: - - name: Git checkout - uses: actions/checkout@v3 - - name: Get latest release tag - uses: oprypin/find-latest-tag@v1 - with: - repository: ${{ github.repository }} - releases-only: true - id: octokit - - name: GET .env - run: | - cp ${{ env.ENV_FILE }} .env - - name: Dotenv action - uses: falti/dotenv-action@v1.0.4 - id: dotenv - - name: Extract variables - shell: bash - run: | - echo "RACK_ENV=${{ env.RACK_ENV }}" >> $GITHUB_OUTPUT - echo "ENV_FILE=${{ env.ENV_FILE }}" >> $GITHUB_OUTPUT - echo "REPOSITORY=${{ github.repository }}" >> $GITHUB_OUTPUT - echo "BRANCH=${{ github.ref_name }}" >> $GITHUB_OUTPUT - echo "TAG=${{ github.ref_name }}" >> $GITHUB_OUTPUT - echo "GIT_SHA=${{ github.sha }}" >> $GITHUB_OUTPUT - echo "GIT_SHA_SHORT=$( git rev-parse --short ${{ github.sha }} )" >> $GITHUB_OUTPUT - echo "LATEST_RELEASE=${{ steps.octokit.outputs.tag }}" >> $GITHUB_OUTPUT - echo "SITE_NAME=${{ steps.dotenv.outputs.SITE_NAME }}" >> $GITHUB_OUTPUT - echo "SITE_URL=${{ steps.dotenv.outputs.SITE_URL }}" >> $GITHUB_OUTPUT - id: extract_variables - - name: Print state - run: | - echo "RACK_ENV = ${{ steps.extract_variables.outputs.RACK_ENV }}" - echo "ENV_FILE = ${{ steps.extract_variables.outputs.ENV_FILE }}" - echo "REPOSITORY = ${{ steps.extract_variables.outputs.REPOSITORY }}" - echo "BRANCH = ${{ steps.extract_variables.outputs.BRANCH }}" - echo "GIT_SHA = ${{ steps.extract_variables.outputs.GIT_SHA }}" - build: - needs: [vars] uses: ./.github/workflows/_build.yml with: - RACK_ENV: ${{ needs.vars.outputs.RACK_ENV }} - ENV_FILE: ${{ needs.vars.outputs.ENV_FILE }} - REPOSITORY: ${{ needs.vars.outputs.REPOSITORY }} - BRANCH: ${{ needs.vars.outputs.BRANCH }} - GIT_SHA: ${{ needs.vars.outputs.GIT_SHA }} - + RACK_ENV: stage + ENV_FILE: .env.stage + GIT_SHA: ${{ github.sha }} + deploy: - needs: [vars, build] + needs: [build] uses: ./.github/workflows/_deploy.yml with: - RACK_ENV: ${{ needs.vars.outputs.RACK_ENV }} - ENV_FILE: ${{ needs.vars.outputs.ENV_FILE }} - REPOSITORY: ${{ needs.vars.outputs.REPOSITORY }} - BRANCH: ${{ needs.vars.outputs.BRANCH }} - GIT_SHA: ${{ needs.vars.outputs.GIT_SHA }} + RACK_ENV: stage + ENV_FILE: .env.stage + GIT_SHA: ${{ github.sha }} secrets: S3_BUCKET: ${{ secrets.STAGE_S3_BUCKET }} S3_REGION: ${{ secrets.STAGE_S3_BUCKET_REGION }} diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index bece8f1..b243e4b 100755 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -5,68 +5,10 @@ on: branches: - master -env: - RACK_ENV: stage - ENV_FILE: .env.stage - jobs: - vars: - runs-on: ubuntu-latest - outputs: - RACK_ENV: ${{ steps.extract_variables.outputs.RACK_ENV }} - ENV_FILE: ${{ steps.extract_variables.outputs.ENV_FILE }} - REPOSITORY: ${{ steps.extract_variables.outputs.REPOSITORY }} - BRANCH: ${{ steps.extract_variables.outputs.BRANCH }} - TAG: ${{ steps.extract_variables.outputs.TAG }} - GIT_SHA: ${{ steps.extract_variables.outputs.GIT_SHA }} - GIT_SHA_SHORT: ${{ steps.extract_variables.outputs.GIT_SHA_SHORT }} - LATEST_RELEASE: ${{ steps.extract_variables.outputs.LATEST_RELEASE }} - SITE_URL: ${{ steps.extract_variables.outputs.SITE_URL }} - SITE_NAME: ${{ steps.extract_variables.outputs.SITE_NAME }} - steps: - - name: Git checkout - uses: actions/checkout@v3 - - name: Get latest release tag - uses: oprypin/find-latest-tag@v1 - with: - repository: ${{ github.repository }} - releases-only: true - id: octokit - - name: GET .env - run: | - cp ${{ env.ENV_FILE }} .env - - name: Dotenv action - uses: falti/dotenv-action@v1.0.4 - id: dotenv - - name: Extract variables - shell: bash - run: | - echo "RACK_ENV=${{ env.RACK_ENV }}" >> $GITHUB_OUTPUT - echo "ENV_FILE=${{ env.ENV_FILE }}" >> $GITHUB_OUTPUT - echo "REPOSITORY=${{ github.repository }}" >> $GITHUB_OUTPUT - echo "BRANCH=${{ github.ref_name }}" >> $GITHUB_OUTPUT - echo "TAG=${{ github.ref_name }}" >> $GITHUB_OUTPUT - echo "GIT_SHA=${{ github.sha }}" >> $GITHUB_OUTPUT - echo "GIT_SHA_SHORT=$( git rev-parse --short ${{ github.sha }} )" >> $GITHUB_OUTPUT - echo "LATEST_RELEASE=${{ steps.octokit.outputs.tag }}" >> $GITHUB_OUTPUT - echo "SITE_NAME=${{ steps.dotenv.outputs.SITE_NAME }}" >> $GITHUB_OUTPUT - echo "SITE_URL=${{ steps.dotenv.outputs.SITE_URL }}" >> $GITHUB_OUTPUT - id: extract_variables - - name: Print state - run: | - echo "RACK_ENV = ${{ steps.extract_variables.outputs.RACK_ENV }}" - echo "ENV_FILE = ${{ steps.extract_variables.outputs.ENV_FILE }}" - echo "REPOSITORY = ${{ steps.extract_variables.outputs.REPOSITORY }}" - echo "BRANCH = ${{ steps.extract_variables.outputs.BRANCH }}" - echo "GIT_SHA = ${{ steps.extract_variables.outputs.GIT_SHA }}" - build: - needs: [vars] uses: ./.github/workflows/_build.yml with: - RACK_ENV: ${{ needs.vars.outputs.RACK_ENV }} - ENV_FILE: ${{ needs.vars.outputs.ENV_FILE }} - REPOSITORY: ${{ needs.vars.outputs.REPOSITORY }} - BRANCH: ${{ needs.vars.outputs.BRANCH }} - GIT_SHA: ${{ needs.vars.outputs.GIT_SHA }} - \ No newline at end of file + RACK_ENV: stage + ENV_FILE: .env.stage + GIT_SHA: ${{ github.sha }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 12398a7..89a147f 100755 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,82 +2,22 @@ name: Release to Production on: release: types: [published] - -env: - RACK_ENV: production - ENV_FILE: .env.production jobs: - vars: - runs-on: ubuntu-latest - outputs: - RACK_ENV: ${{ steps.extract_variables.outputs.RACK_ENV }} - ENV_FILE: ${{ steps.extract_variables.outputs.ENV_FILE }} - REPOSITORY: ${{ steps.extract_variables.outputs.REPOSITORY }} - BRANCH: ${{ steps.extract_variables.outputs.BRANCH }} - TAG: ${{ steps.extract_variables.outputs.TAG }} - GIT_SHA: ${{ steps.extract_variables.outputs.GIT_SHA }} - GIT_SHA_SHORT: ${{ steps.extract_variables.outputs.GIT_SHA_SHORT }} - LATEST_RELEASE: ${{ steps.extract_variables.outputs.LATEST_RELEASE }} - SITE_URL: ${{ steps.extract_variables.outputs.SITE_URL }} - SITE_NAME: ${{ steps.extract_variables.outputs.SITE_NAME }} - steps: - - name: Git checkout - uses: actions/checkout@v3 - - name: Get latest release tag - uses: oprypin/find-latest-tag@v1 - with: - repository: ${{ github.repository }} - releases-only: true - id: octokit - - name: GET .env - run: | - cp ${{ env.ENV_FILE }} .env - - name: Dotenv action - uses: falti/dotenv-action@v1.0.4 - id: dotenv - - name: Extract variables - shell: bash - run: | - echo "RACK_ENV=${{ env.RACK_ENV }}" >> $GITHUB_OUTPUT - echo "ENV_FILE=${{ env.ENV_FILE }}" >> $GITHUB_OUTPUT - echo "REPOSITORY=${{ github.repository }}" >> $GITHUB_OUTPUT - echo "BRANCH=${{ github.ref_name }}" >> $GITHUB_OUTPUT - echo "TAG=${{ github.ref_name }}" >> $GITHUB_OUTPUT - echo "GIT_SHA=${{ github.sha }}" >> $GITHUB_OUTPUT - echo "GIT_SHA_SHORT=$( git rev-parse --short ${{ github.sha }} )" >> $GITHUB_OUTPUT - echo "LATEST_RELEASE=${{ steps.octokit.outputs.tag }}" >> $GITHUB_OUTPUT - echo "SITE_NAME=${{ steps.dotenv.outputs.SITE_NAME }}" >> $GITHUB_OUTPUT - echo "SITE_URL=${{ steps.dotenv.outputs.SITE_URL }}" >> $GITHUB_OUTPUT - id: extract_variables - - name: Print state - run: | - echo "RACK_ENV = ${{ steps.extract_variables.outputs.RACK_ENV }}" - echo "ENV_FILE = ${{ steps.extract_variables.outputs.ENV_FILE }}" - echo "REPOSITORY = ${{ steps.extract_variables.outputs.REPOSITORY }}" - echo "BRANCH = ${{ steps.extract_variables.outputs.BRANCH }}" - echo "GIT_SHA = ${{ steps.extract_variables.outputs.GIT_SHA }}" - build: - needs: [vars] uses: ./.github/workflows/_build.yml with: - RACK_ENV: ${{ needs.vars.outputs.RACK_ENV }} - ENV_FILE: ${{ needs.vars.outputs.ENV_FILE }} - REPOSITORY: ${{ needs.vars.outputs.REPOSITORY }} - BRANCH: ${{ needs.vars.outputs.BRANCH }} - GIT_SHA: ${{ needs.vars.outputs.GIT_SHA }} - - # Note, we don't deploy to test. + RACK_ENV: production + ENV_FILE: .env.production + GIT_SHA: ${{ github.sha }} + deploy: - needs: [vars, build] + needs: [build] uses: ./.github/workflows/_deploy.yml with: - RACK_ENV: ${{ needs.vars.outputs.RACK_ENV }} - ENV_FILE: ${{ needs.vars.outputs.ENV_FILE }} - REPOSITORY: ${{ needs.vars.outputs.REPOSITORY }} - BRANCH: ${{ needs.vars.outputs.BRANCH }} - GIT_SHA: ${{ needs.vars.outputs.GIT_SHA }} + RACK_ENV: production + ENV_FILE: .env.production + GIT_SHA: ${{ github.sha }} secrets: S3_BUCKET: ${{ secrets.S3_BUCKET }} S3_REGION: ${{ secrets.S3_BUCKET_REGION }} diff --git a/.github/workflows/test_branch.yml b/.github/workflows/test_branch.yml index f9bda4a..0d60248 100755 --- a/.github/workflows/test_branch.yml +++ b/.github/workflows/test_branch.yml @@ -1,68 +1,11 @@ name: Test Branch on: workflow_dispatch: - -env: - RACK_ENV: stage - ENV_FILE: .env.stage jobs: - vars: - runs-on: ubuntu-latest - outputs: - RACK_ENV: ${{ steps.extract_variables.outputs.RACK_ENV }} - ENV_FILE: ${{ steps.extract_variables.outputs.ENV_FILE }} - REPOSITORY: ${{ steps.extract_variables.outputs.REPOSITORY }} - BRANCH: ${{ steps.extract_variables.outputs.BRANCH }} - TAG: ${{ steps.extract_variables.outputs.TAG }} - GIT_SHA: ${{ steps.extract_variables.outputs.GIT_SHA }} - GIT_SHA_SHORT: ${{ steps.extract_variables.outputs.GIT_SHA_SHORT }} - LATEST_RELEASE: ${{ steps.extract_variables.outputs.LATEST_RELEASE }} - SITE_URL: ${{ steps.extract_variables.outputs.SITE_URL }} - SITE_NAME: ${{ steps.extract_variables.outputs.SITE_NAME }} - steps: - - name: Git checkout - uses: actions/checkout@v3 - - name: Get latest release tag - uses: oprypin/find-latest-tag@v1 - with: - repository: ${{ github.repository }} - releases-only: true - id: octokit - - name: GET .env - run: | - cp ${{ env.ENV_FILE }} .env - - name: Dotenv action - uses: falti/dotenv-action@v1.0.4 - id: dotenv - - name: Extract variables - shell: bash - run: | - echo "RACK_ENV=${{ env.RACK_ENV }}" >> $GITHUB_OUTPUT - echo "ENV_FILE=${{ env.ENV_FILE }}" >> $GITHUB_OUTPUT - echo "REPOSITORY=${{ github.repository }}" >> $GITHUB_OUTPUT - echo "BRANCH=${{ github.ref_name }}" >> $GITHUB_OUTPUT - echo "TAG=${{ github.ref_name }}" >> $GITHUB_OUTPUT - echo "GIT_SHA=${{ github.sha }}" >> $GITHUB_OUTPUT - echo "GIT_SHA_SHORT=$( git rev-parse --short ${{ github.sha }} )" >> $GITHUB_OUTPUT - echo "LATEST_RELEASE=${{ steps.octokit.outputs.tag }}" >> $GITHUB_OUTPUT - echo "SITE_NAME=${{ steps.dotenv.outputs.SITE_NAME }}" >> $GITHUB_OUTPUT - echo "SITE_URL=${{ steps.dotenv.outputs.SITE_URL }}" >> $GITHUB_OUTPUT - id: extract_variables - - name: Print state - run: | - echo "RACK_ENV = ${{ steps.extract_variables.outputs.RACK_ENV }}" - echo "ENV_FILE = ${{ steps.extract_variables.outputs.ENV_FILE }}" - echo "REPOSITORY = ${{ steps.extract_variables.outputs.REPOSITORY }}" - echo "BRANCH = ${{ steps.extract_variables.outputs.BRANCH }}" - echo "GIT_SHA = ${{ steps.extract_variables.outputs.GIT_SHA }}" - build: - needs: [vars] uses: ./.github/workflows/_build.yml with: - RACK_ENV: ${{ needs.vars.outputs.RACK_ENV }} - ENV_FILE: ${{ needs.vars.outputs.ENV_FILE }} - REPOSITORY: ${{ needs.vars.outputs.REPOSITORY }} - BRANCH: ${{ needs.vars.outputs.BRANCH }} - GIT_SHA: ${{ needs.vars.outputs.GIT_SHA }} + RACK_ENV: stage + ENV_FILE: .env.stage + GIT_SHA: ${{ github.sha }}