Browse Source

Update workflows

pull/503/head
Paul Robert Lloyd 3 years ago
parent
commit
5feb225505
  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: on:
release: release:
@ -26,8 +26,8 @@ jobs:
POSTGRES_DB: data_collector POSTGRES_DB: data_collector
ports: ports:
- 5432:5432 - 5432:5432
# needed because the postgres container does not provide a healthcheck # Needed because the Postgres container does not provide a health check
# tmpfs makes DB 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
@ -47,25 +47,28 @@ jobs:
id: latestrelease id: latestrelease
run: | run: |
echo "::set-output name=releasetag::$(curl -s https://api.github.com/repos/${REPO_URL}/releases/latest | jq '.tag_name' | sed 's/\"//g')" 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 - name: Confirm release tag
run: | run: |
echo ${{ steps.latestrelease.outputs.releasetag }} echo ${{ steps.latestrelease.outputs.releasetag }}
- name: Checkout tag - name: Checkout tag
uses: actions/checkout@v2 uses: actions/checkout@v3
with: with:
ref: ${{ steps.latestrelease.outputs.releasetag }} ref: ${{ steps.latestrelease.outputs.releasetag }}
- name: Set up Ruby - name: Set up Ruby
uses: ruby/setup-ruby@v1 uses: ruby/setup-ruby@v1
with: with:
# runs 'bundle install' and caches installed gems automatically
bundler-cache: true bundler-cache: true
- name: Set up node - name: Set up node
uses: actions/setup-node@v2 uses: actions/setup-node@v3
with: with:
node-version: '16' cache: yarn
node-version: 16
- name: Create DB - name: Create database
run: | run: |
bundle exec rake db:prepare bundle exec rake db:prepare
@ -80,23 +83,25 @@ jobs:
lint: lint:
name: Lint name: Lint
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Get latest release with tag - name: Get latest release with tag
id: latestrelease id: latestrelease
run: | run: |
echo "::set-output name=releasetag::$(curl -s https://api.github.com/repos/${REPO_URL}/releases/latest | jq '.tag_name' | sed 's/\"//g')" 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 - name: Confirm release tag
run: | run: |
echo ${{ steps.latestrelease.outputs.releasetag }} echo ${{ steps.latestrelease.outputs.releasetag }}
- name: Checkout tag - name: Checkout tag
uses: actions/checkout@v2 uses: actions/checkout@v3
with: with:
ref: ${{ steps.latestrelease.outputs.releasetag }} ref: ${{ steps.latestrelease.outputs.releasetag }}
- name: Set up Ruby - name: Set up Ruby
uses: ruby/setup-ruby@v1 uses: ruby/setup-ruby@v1
with: with:
# runs 'bundle install' and caches installed gems automatically
bundler-cache: true bundler-cache: true
- name: Rubocop - name: Rubocop
@ -106,23 +111,25 @@ jobs:
audit: audit:
name: Audit dependencies name: Audit dependencies
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Get latest release with tag - name: Get latest release with tag
id: latestrelease id: latestrelease
run: | run: |
echo "::set-output name=releasetag::$(curl -s https://api.github.com/repos/${REPO_URL}/releases/latest | jq '.tag_name' | sed 's/\"//g')" 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 - name: Confirm release tag
run: | run: |
echo ${{ steps.latestrelease.outputs.releasetag }} echo ${{ steps.latestrelease.outputs.releasetag }}
- name: Checkout tag - name: Checkout tag
uses: actions/checkout@v2 uses: actions/checkout@v3
with: with:
ref: ${{ steps.latestrelease.outputs.releasetag }} ref: ${{ steps.latestrelease.outputs.releasetag }}
- name: Set up Ruby - name: Set up Ruby
uses: ruby/setup-ruby@v1 uses: ruby/setup-ruby@v1
with: with:
# runs 'bundle install' and caches installed gems automatically
bundler-cache: true bundler-cache: true
- name: Audit - name: Audit
@ -131,10 +138,9 @@ jobs:
deploy: deploy:
name: Deploy name: Deploy
concurrency: 'production' concurrency: "production"
runs-on: ubuntu-latest runs-on: ubuntu-latest
environment: 'production' environment: "production"
needs: [lint, test, audit] needs: [lint, test, audit]
steps: steps:
@ -142,11 +148,13 @@ jobs:
id: latestrelease id: latestrelease
run: | run: |
echo "::set-output name=releasetag::$(curl -s https://api.github.com/repos/${REPO_URL}/releases/latest | jq '.tag_name' | sed 's/\"//g')" 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 - name: Confirm release tag
run: | run: |
echo ${{ steps.latestrelease.outputs.releasetag }} echo ${{ steps.latestrelease.outputs.releasetag }}
- name: Checkout tag - name: Checkout tag
uses: actions/checkout@v2 uses: actions/checkout@v3
with: with:
ref: ${{ steps.latestrelease.outputs.releasetag }} 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 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 }}

38
.github/workflows/staging_pipeline.yml

@ -1,4 +1,4 @@
name: 'Staging CI/CD Pipeline' name: Staging CI/CD Pipeline
on: on:
push: push:
@ -25,14 +25,15 @@ jobs:
POSTGRES_DB: data_collector POSTGRES_DB: data_collector
ports: ports:
- 5432:5432 - 5432:5432
# needed because the postgres container does not provide a healthcheck # Needed because the Postgres container does not provide a health check
# tmpfs makes DB 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
@ -43,23 +44,24 @@ jobs:
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Set up Ruby - name: Set up Ruby
uses: ruby/setup-ruby@v1 uses: ruby/setup-ruby@v1
with: with:
# runs 'bundle install' and caches installed gems automatically
bundler-cache: true bundler-cache: true
- name: Set up node
uses: actions/setup-node@v2 - name: Set up Node.js
uses: actions/setup-node@v3
with: with:
node-version: '16' cache: yarn
node-version: 16
- name: Create DB - 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
@ -70,14 +72,14 @@ jobs:
lint: lint:
name: Lint name: Lint
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Set up Ruby - name: Set up Ruby
uses: ruby/setup-ruby@v1 uses: ruby/setup-ruby@v1
with: with:
# runs 'bundle install' and caches installed gems automatically
bundler-cache: true bundler-cache: true
- name: Rubocop - name: Rubocop
@ -87,14 +89,14 @@ jobs:
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@v2 uses: actions/checkout@v3
- name: Set up Ruby - name: Set up Ruby
uses: ruby/setup-ruby@v1 uses: ruby/setup-ruby@v1
with: with:
# runs 'bundle install' and caches installed gems automatically
bundler-cache: true bundler-cache: true
- name: Audit - name: Audit
@ -103,16 +105,15 @@ jobs:
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, audit] needs: [lint, test, audit]
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Install Cloud Foundry CLI - name: Install Cloud Foundry CLI
run: | 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 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 }}

Loading…
Cancel
Save