Browse Source

Merge pull request #503 from communitiesuk/update-workflows

pull/504/head
Paul Robert Lloyd 3 years ago committed by GitHub
parent
commit
2c2bdf79ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 41
      .github/workflows/production_pipeline.yml
  2. 38
      .github/workflows/staging_pipeline.yml

41
.github/workflows/production_pipeline.yml

@ -1,4 +1,4 @@
name: 'Production CI/CD Pipeline'
name: Production CI/CD Pipeline
on:
release:
@ -26,8 +26,8 @@ jobs:
POSTGRES_DB: data_collector
ports:
- 5432:5432
# needed because the postgres container does not provide a healthcheck
# tmpfs makes DB faster by using RAM
# Needed because the Postgres container does not provide a health check
# tmpfs makes database faster by using RAM
options: >-
--mount type=tmpfs,destination=/var/lib/postgresql/data
--health-cmd pg_isready
@ -47,25 +47,28 @@ jobs:
id: latestrelease
run: |
echo "::set-output name=releasetag::$(curl -s https://api.github.com/repos/${REPO_URL}/releases/latest | jq '.tag_name' | sed 's/\"//g')"
- name: Confirm release tag
run: |
echo ${{ steps.latestrelease.outputs.releasetag }}
- name: Checkout tag
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
ref: ${{ steps.latestrelease.outputs.releasetag }}
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
# runs 'bundle install' and caches installed gems automatically
bundler-cache: true
- name: Set up node
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: '16'
cache: yarn
node-version: 16
- name: Create DB
- name: Create database
run: |
bundle exec rake db:prepare
@ -80,23 +83,25 @@ jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Get latest release with tag
id: latestrelease
run: |
echo "::set-output name=releasetag::$(curl -s https://api.github.com/repos/${REPO_URL}/releases/latest | jq '.tag_name' | sed 's/\"//g')"
- name: Confirm release tag
run: |
echo ${{ steps.latestrelease.outputs.releasetag }}
- name: Checkout tag
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
ref: ${{ steps.latestrelease.outputs.releasetag }}
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
# runs 'bundle install' and caches installed gems automatically
bundler-cache: true
- name: Rubocop
@ -106,23 +111,25 @@ jobs:
audit:
name: Audit dependencies
runs-on: ubuntu-latest
steps:
- name: Get latest release with tag
id: latestrelease
run: |
echo "::set-output name=releasetag::$(curl -s https://api.github.com/repos/${REPO_URL}/releases/latest | jq '.tag_name' | sed 's/\"//g')"
- name: Confirm release tag
run: |
echo ${{ steps.latestrelease.outputs.releasetag }}
- name: Checkout tag
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
ref: ${{ steps.latestrelease.outputs.releasetag }}
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
# runs 'bundle install' and caches installed gems automatically
bundler-cache: true
- name: Audit
@ -131,10 +138,9 @@ jobs:
deploy:
name: Deploy
concurrency: 'production'
concurrency: "production"
runs-on: ubuntu-latest
environment: 'production'
environment: "production"
needs: [lint, test, audit]
steps:
@ -142,11 +148,13 @@ jobs:
id: latestrelease
run: |
echo "::set-output name=releasetag::$(curl -s https://api.github.com/repos/${REPO_URL}/releases/latest | jq '.tag_name' | sed 's/\"//g')"
- name: Confirm release tag
run: |
echo ${{ steps.latestrelease.outputs.releasetag }}
- name: Checkout tag
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
ref: ${{ steps.latestrelease.outputs.releasetag }}
@ -156,6 +164,7 @@ jobs:
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 install cf8-cli
- name: Deploy
env:
CF_USERNAME: ${{ secrets.CF_USERNAME }}

38
.github/workflows/staging_pipeline.yml

@ -1,4 +1,4 @@
name: 'Staging CI/CD Pipeline'
name: Staging CI/CD Pipeline
on:
push:
@ -25,14 +25,15 @@ jobs:
POSTGRES_DB: data_collector
ports:
- 5432:5432
# needed because the postgres container does not provide a healthcheck
# tmpfs makes DB faster by using RAM
# Needed because the Postgres container does not provide a health check
# tmpfs makes database faster by using RAM
options: >-
--mount type=tmpfs,destination=/var/lib/postgresql/data
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
RAILS_ENV: test
GEMFILE_RUBY_VERSION: 3.1.1
@ -43,23 +44,24 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
# runs 'bundle install' and caches installed gems automatically
bundler-cache: true
- name: Set up node
uses: actions/setup-node@v2
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '16'
cache: yarn
node-version: 16
- name: Create DB
- name: Create database
run: |
bundle exec rake db:prepare
- name: Compile Assets
- name: Compile assets
run: |
bundle exec rake assets:precompile
@ -70,14 +72,14 @@ jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
# runs 'bundle install' and caches installed gems automatically
bundler-cache: true
- name: Rubocop
@ -87,14 +89,14 @@ jobs:
audit:
name: Audit dependencies
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
# runs 'bundle install' and caches installed gems automatically
bundler-cache: true
- name: Audit
@ -103,16 +105,15 @@ jobs:
deploy:
name: Deploy
concurrency: 'staging'
concurrency: staging
runs-on: ubuntu-latest
environment: 'staging'
environment: staging
if: github.ref == 'refs/heads/main'
needs: [lint, test, audit]
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Install Cloud Foundry CLI
run: |
@ -120,6 +121,7 @@ jobs:
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 install cf8-cli
- name: Deploy
env:
CF_USERNAME: ${{ secrets.CF_USERNAME }}

Loading…
Cancel
Save