Browse Source

Only run AWS deploy, and do so on push (no need for merge to main)

ForceAwsTaskFailure
Sam Seed 1 year ago
parent
commit
186a0572a9
  1. 435
      .github/workflows/staging_pipeline.yml

435
.github/workflows/staging_pipeline.yml

@ -4,6 +4,7 @@ on:
push: push:
branches: branches:
- main - main
- ForceAwsTaskFailure
pull_request: pull_request:
types: types:
- opened - opened
@ -15,226 +16,226 @@ defaults:
shell: bash shell: bash
jobs: jobs:
test: # test:
name: Tests # name: Tests
runs-on: ubuntu-latest # runs-on: ubuntu-latest
services: # services:
postgres: # postgres:
image: postgres:13.5 # image: postgres:13.5
env: # env:
POSTGRES_PASSWORD: password # POSTGRES_PASSWORD: password
POSTGRES_USER: postgres # POSTGRES_USER: postgres
POSTGRES_DB: data_collector # POSTGRES_DB: data_collector
ports: # ports:
- 5432:5432 # - 5432:5432
# Needed because the Postgres container does not provide a health check # # Needed because the Postgres container does not provide a health check
# tmpfs makes database faster by using RAM # # tmpfs makes database faster by using RAM
options: >- # options: >-
--mount type=tmpfs,destination=/var/lib/postgresql/data # --mount type=tmpfs,destination=/var/lib/postgresql/data
--health-cmd pg_isready # --health-cmd pg_isready
--health-interval 10s # --health-interval 10s
--health-timeout 5s # --health-timeout 5s
--health-retries 5 # --health-retries 5
env: # env:
RAILS_ENV: test # RAILS_ENV: test
GEMFILE_RUBY_VERSION: 3.1.1 # GEMFILE_RUBY_VERSION: 3.1.1
DB_HOST: localhost # DB_HOST: localhost
DB_DATABASE: data_collector # DB_DATABASE: data_collector
DB_USERNAME: postgres # DB_USERNAME: postgres
DB_PASSWORD: password # DB_PASSWORD: password
RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }} # RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }}
PARALLEL_TEST_PROCESSORS: 4 # PARALLEL_TEST_PROCESSORS: 4
steps: # steps:
- name: Checkout # - name: Checkout
uses: actions/checkout@v3 # uses: actions/checkout@v3
- name: Set up Ruby # - name: Set up Ruby
uses: ruby/setup-ruby@v1 # uses: ruby/setup-ruby@v1
with: # with:
bundler-cache: true # bundler-cache: true
- name: Set up Node.js # - name: Set up Node.js
uses: actions/setup-node@v3 # uses: actions/setup-node@v3
with: # with:
cache: yarn # cache: yarn
node-version: 18 # node-version: 18
- name: Create database # - name: Create database
run: | # run: |
bundle exec rake parallel:setup # bundle exec rake parallel:setup
- name: Compile assets # - name: Compile assets
run: | # run: |
bundle exec rake assets:precompile # bundle exec rake assets:precompile
- name: Run tests # - name: Run tests
run: | # run: |
bundle exec rake parallel:spec['spec\/(?!features)'] # bundle exec rake parallel:spec['spec\/(?!features)']
feature_test: # feature_test:
name: Feature Tests # name: Feature Tests
runs-on: ubuntu-latest # runs-on: ubuntu-latest
services: # services:
postgres: # postgres:
image: postgres:13.5 # image: postgres:13.5
env: # env:
POSTGRES_PASSWORD: password # POSTGRES_PASSWORD: password
POSTGRES_USER: postgres # POSTGRES_USER: postgres
POSTGRES_DB: data_collector # POSTGRES_DB: data_collector
ports: # ports:
- 5432:5432 # - 5432:5432
# Needed because the Postgres container does not provide a health check # # Needed because the Postgres container does not provide a health check
# tmpfs makes database faster by using RAM # # tmpfs makes database faster by using RAM
options: >- # options: >-
--mount type=tmpfs,destination=/var/lib/postgresql/data # --mount type=tmpfs,destination=/var/lib/postgresql/data
--health-cmd pg_isready # --health-cmd pg_isready
--health-interval 10s # --health-interval 10s
--health-timeout 5s # --health-timeout 5s
--health-retries 5 # --health-retries 5
env: # env:
RAILS_ENV: test # RAILS_ENV: test
GEMFILE_RUBY_VERSION: 3.1.1 # GEMFILE_RUBY_VERSION: 3.1.1
DB_HOST: localhost # DB_HOST: localhost
DB_DATABASE: data_collector # DB_DATABASE: data_collector
DB_USERNAME: postgres # DB_USERNAME: postgres
DB_PASSWORD: password # DB_PASSWORD: password
RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }} # RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }}
steps: # steps:
- name: Checkout # - name: Checkout
uses: actions/checkout@v3 # uses: actions/checkout@v3
- name: Set up Ruby # - name: Set up Ruby
uses: ruby/setup-ruby@v1 # uses: ruby/setup-ruby@v1
with: # with:
bundler-cache: true # bundler-cache: true
- name: Set up Node.js # - name: Set up Node.js
uses: actions/setup-node@v3 # uses: actions/setup-node@v3
with: # with:
cache: yarn # cache: yarn
node-version: 18 # node-version: 18
- name: Create database # - name: Create database
run: | # run: |
bundle exec rake db:prepare # bundle exec rake db:prepare
- name: Compile assets # - name: Compile assets
run: | # run: |
bundle exec rake assets:precompile # bundle exec rake assets:precompile
- name: Run tests # - name: Run tests
run: | # run: |
bundle exec rspec spec/features --fail-fast # bundle exec rspec spec/features --fail-fast
lint: # lint:
name: Lint # name: Lint
runs-on: ubuntu-latest # runs-on: ubuntu-latest
steps: # steps:
- name: Checkout # - name: Checkout
uses: actions/checkout@v3 # uses: actions/checkout@v3
- name: Set up Ruby # - name: Set up Ruby
uses: ruby/setup-ruby@v1 # uses: ruby/setup-ruby@v1
with: # with:
bundler-cache: true # bundler-cache: true
- name: Set up Node.js # - name: Set up Node.js
uses: actions/setup-node@v3 # uses: actions/setup-node@v3
with: # with:
cache: yarn # cache: yarn
node-version: 18 # node-version: 18
- name: Install packages and symlink local dependencies # - name: Install packages and symlink local dependencies
run: | # run: |
yarn install --immutable --immutable-cache --check-cache # yarn install --immutable --immutable-cache --check-cache
- name: Lint # - name: Lint
run: | # run: |
bundle exec rake lint # bundle exec rake lint
audit: # audit:
name: Audit dependencies # name: Audit dependencies
runs-on: ubuntu-latest # runs-on: ubuntu-latest
steps: # steps:
- name: Checkout # - name: Checkout
uses: actions/checkout@v3 # uses: actions/checkout@v3
- name: Set up Ruby # - name: Set up Ruby
uses: ruby/setup-ruby@v1 # uses: ruby/setup-ruby@v1
with: # with:
bundler-cache: true # bundler-cache: true
- name: Audit # - name: Audit
run: | # run: |
bundle exec bundler-audit # bundle exec bundler-audit
deploy: # deploy:
name: Deploy # name: Deploy
concurrency: staging # concurrency: staging
runs-on: ubuntu-latest # runs-on: ubuntu-latest
environment: staging # environment: staging
if: github.ref == 'refs/heads/main' # if: github.ref == 'refs/heads/main'
needs: [lint, test, feature_test, audit] # needs: [lint, test, feature_test, audit]
steps: # steps:
- name: Checkout code # - name: Checkout code
uses: actions/checkout@v3 # uses: actions/checkout@v3
- name: Install Cloud Foundry CLI # - name: Install Cloud Foundry CLI
run: | # run: |
wget --user-agent "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.3 Safari/605.1.15" -q -O - https://packages.cloudfoundry.org/debian/cli.cloudfoundry.org.key | sudo apt-key add - # wget --user-agent "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.3 Safari/605.1.15" -q -O - https://packages.cloudfoundry.org/debian/cli.cloudfoundry.org.key | sudo apt-key add -
echo "deb https://packages.cloudfoundry.org/debian stable main" | sudo tee /etc/apt/sources.list.d/cloudfoundry-cli.list # echo "deb https://packages.cloudfoundry.org/debian stable main" | sudo tee /etc/apt/sources.list.d/cloudfoundry-cli.list
sudo apt-get update # sudo apt-get update
sudo apt-get install cf8-cli # sudo apt-get install cf8-cli
- name: Deploy # - name: Deploy
env: # env:
CF_USERNAME: ${{ secrets.CF_USERNAME }} # CF_USERNAME: ${{ secrets.CF_USERNAME }}
CF_PASSWORD: ${{ secrets.CF_PASSWORD }} # CF_PASSWORD: ${{ secrets.CF_PASSWORD }}
CF_API_ENDPOINT: ${{ secrets.CF_API_ENDPOINT }} # CF_API_ENDPOINT: ${{ secrets.CF_API_ENDPOINT }}
CF_SPACE: ${{ secrets.CF_SPACE }} # CF_SPACE: ${{ secrets.CF_SPACE }}
CF_ORG: ${{ secrets.CF_ORG }} # CF_ORG: ${{ secrets.CF_ORG }}
API_USER: ${{ secrets.API_USER }} # API_USER: ${{ secrets.API_USER }}
API_KEY: ${{ secrets.API_KEY }} # API_KEY: ${{ secrets.API_KEY }}
APP_NAME: dluhc-core-staging # APP_NAME: dluhc-core-staging
GOVUK_NOTIFY_API_KEY: ${{ secrets.GOVUK_NOTIFY_API_KEY }} # GOVUK_NOTIFY_API_KEY: ${{ secrets.GOVUK_NOTIFY_API_KEY }}
APP_HOST: ${{ secrets.APP_HOST }} # APP_HOST: ${{ secrets.APP_HOST }}
RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }} # RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }}
OS_DATA_KEY: ${{ secrets.OS_DATA_KEY }} # OS_DATA_KEY: ${{ secrets.OS_DATA_KEY }}
IMPORT_PAAS_INSTANCE: ${{ secrets.IMPORT_PAAS_INSTANCE }} # IMPORT_PAAS_INSTANCE: ${{ secrets.IMPORT_PAAS_INSTANCE }}
EXPORT_PAAS_INSTANCE: ${{ secrets.EXPORT_PAAS_INSTANCE }} # EXPORT_PAAS_INSTANCE: ${{ secrets.EXPORT_PAAS_INSTANCE }}
S3_CONFIG: ${{ secrets.S3_CONFIG }} # S3_CONFIG: ${{ secrets.S3_CONFIG }}
CSV_DOWNLOAD_PAAS_INSTANCE: ${{ secrets.CSV_DOWNLOAD_PAAS_INSTANCE }} # CSV_DOWNLOAD_PAAS_INSTANCE: ${{ secrets.CSV_DOWNLOAD_PAAS_INSTANCE }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN }} # SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
run: | # run: |
cf api $CF_API_ENDPOINT # cf api $CF_API_ENDPOINT
cf auth # cf auth
cf target -o $CF_ORG -s $CF_SPACE # cf target -o $CF_ORG -s $CF_SPACE
cf set-env $APP_NAME API_USER $API_USER # cf set-env $APP_NAME API_USER $API_USER
cf set-env $APP_NAME API_KEY $API_KEY # cf set-env $APP_NAME API_KEY $API_KEY
cf set-env $APP_NAME GOVUK_NOTIFY_API_KEY $GOVUK_NOTIFY_API_KEY # cf set-env $APP_NAME GOVUK_NOTIFY_API_KEY $GOVUK_NOTIFY_API_KEY
cf set-env $APP_NAME APP_HOST $APP_HOST # cf set-env $APP_NAME APP_HOST $APP_HOST
cf set-env $APP_NAME RAILS_MASTER_KEY $RAILS_MASTER_KEY # cf set-env $APP_NAME RAILS_MASTER_KEY $RAILS_MASTER_KEY
cf set-env $APP_NAME OS_DATA_KEY $OS_DATA_KEY # cf set-env $APP_NAME OS_DATA_KEY $OS_DATA_KEY
cf set-env $APP_NAME IMPORT_PAAS_INSTANCE $IMPORT_PAAS_INSTANCE # cf set-env $APP_NAME IMPORT_PAAS_INSTANCE $IMPORT_PAAS_INSTANCE
cf set-env $APP_NAME EXPORT_PAAS_INSTANCE $EXPORT_PAAS_INSTANCE # cf set-env $APP_NAME EXPORT_PAAS_INSTANCE $EXPORT_PAAS_INSTANCE
cf set-env $APP_NAME S3_CONFIG $S3_CONFIG # cf set-env $APP_NAME S3_CONFIG $S3_CONFIG
cf set-env $APP_NAME CSV_DOWNLOAD_PAAS_INSTANCE $CSV_DOWNLOAD_PAAS_INSTANCE # cf set-env $APP_NAME CSV_DOWNLOAD_PAAS_INSTANCE $CSV_DOWNLOAD_PAAS_INSTANCE
cf set-env $APP_NAME SENTRY_DSN $SENTRY_DSN # cf set-env $APP_NAME SENTRY_DSN $SENTRY_DSN
cf push $APP_NAME --strategy rolling -t 180 # cf push $APP_NAME --strategy rolling -t 180
aws_deploy: aws_deploy:
name: AWS Deploy name: AWS Deploy
if: github.ref == 'refs/heads/main' if: github.ref == 'refs/heads/ForceAwsTaskFailure'
needs: [lint, test, feature_test, audit] # needs: [lint, test, feature_test, audit]
uses: ./.github/workflows/aws_deploy.yml uses: ./.github/workflows/aws_deploy.yml
with: with:
aws_account_id: 107155005276 aws_account_id: 107155005276

Loading…
Cancel
Save