Submit social housing lettings and sales data (CORE)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

173 lines
6.4 KiB

name: Review app pipeline
concurrency: ${{ github.workflow }}-${{ github.event.pull_request.number }}
on:
pull_request:
types:
- opened
- synchronize
- reopened
workflow_dispatch:
defaults:
run:
shell: bash
jobs:
postgres:
name: Provision postgres
runs-on: ubuntu-latest
environment: staging
steps:
- name: Install Cloud Foundry CLI
run: |
wget -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
sudo apt-get update
sudo apt-get install cf8-cli
- name: Provision postgres
env:
CF_USERNAME: ${{ secrets.CF_USERNAME }}
CF_PASSWORD: ${{ secrets.CF_PASSWORD }}
CF_API_ENDPOINT: ${{ secrets.CF_API_ENDPOINT }}
CF_SPACE: dev
CF_ORG: ${{ secrets.CF_ORG }}
run: |
cf api $CF_API_ENDPOINT
cf auth
cf target -o $CF_ORG -s $CF_SPACE
cf create-service postgres tiny-unencrypted-13 dluhc-core-review-${{ github.event.pull_request.number }}-postgres --wait
redis:
name: Provision redis
runs-on: ubuntu-latest
environment: staging
steps:
- name: Install Cloud Foundry CLI
run: |
wget -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
sudo apt-get update
sudo apt-get install cf8-cli
- name: Provision redis
env:
CF_USERNAME: ${{ secrets.CF_USERNAME }}
CF_PASSWORD: ${{ secrets.CF_PASSWORD }}
CF_API_ENDPOINT: ${{ secrets.CF_API_ENDPOINT }}
CF_SPACE: dev
CF_ORG: ${{ secrets.CF_ORG }}
run: |
cf api $CF_API_ENDPOINT
cf auth
cf target -o $CF_ORG -s $CF_SPACE
cf create-service redis micro-6.x dluhc-core-review-${{ github.event.pull_request.number }}-redis --wait
deploy:
name: Deploy review app
runs-on: ubuntu-latest
environment: staging
needs: [postgres, redis]
permissions:
issues: write
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install Cloud Foundry CLI
run: |
wget -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
sudo apt-get update
sudo apt-get install cf8-cli
- name: Setup review app without starting
env:
CF_USERNAME: ${{ secrets.CF_USERNAME }}
CF_PASSWORD: ${{ secrets.CF_PASSWORD }}
CF_API_ENDPOINT: ${{ secrets.CF_API_ENDPOINT }}
CF_SPACE: dev
CF_ORG: ${{ secrets.CF_ORG }}
APP_NAME: dluhc-core-review-${{ github.event.pull_request.number }}
run: |
cf api $CF_API_ENDPOINT
cf auth
cf target -o $CF_ORG -s $CF_SPACE
cf push $APP_NAME \
--manifest ./config/cloud_foundry/review_manifest.yml \
--no-start
- name: Set environment variables
env:
APP_NAME: dluhc-core-review-${{ github.event.pull_request.number }}
API_USER: ${{ secrets.API_USER }}
API_KEY: ${{ secrets.API_KEY }}
GOVUK_NOTIFY_API_KEY: ${{ secrets.GOVUK_NOTIFY_API_KEY }}
RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }}
IMPORT_PAAS_INSTANCE: ${{ secrets.IMPORT_PAAS_INSTANCE }}
EXPORT_PAAS_INSTANCE: ${{ secrets.EXPORT_PAAS_INSTANCE }}
S3_CONFIG: ${{ secrets.S3_CONFIG }}
CSV_DOWNLOAD_PAAS_INSTANCE: ${{ secrets.CSV_DOWNLOAD_PAAS_INSTANCE }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
run: |
cf set-env $APP_NAME API_USER $API_USER
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 RAILS_MASTER_KEY $RAILS_MASTER_KEY
cf set-env $APP_NAME IMPORT_PAAS_INSTANCE $IMPORT_PAAS_INSTANCE
cf set-env $APP_NAME EXPORT_PAAS_INSTANCE "dluhc-core-review-export-bucket"
cf set-env $APP_NAME S3_CONFIG $S3_CONFIG
CLDC-1826 lettings log codes only download (#1268) * update seeds to add self in review env, change spec to reflect this, update config yml to allow csv exports in review * update interface of relevant methods EmailCsvJob, LettingsLog.to_csv and LettingsLogCsvService consume codes_only flag * update tests including adding a new csv file to test against * update LettingsLogCsvService to output codes only csv * correct minor error and linting * enable codes only download in UI - add link on lettings log index page - pass codes_only flag through params in relevant links and methods - convert flag to boolean in controller methods * ensure link displayed successfully for all renderings of logs_list and params passed through relevant methods in organisations controller * fix existing tests * correct linting thing * correct linting error * update tests for lettings log controller * correct linting errors * update organisations controller tests * make minor changes after code review * remove changes made for testing on review app * make codes only download visible to support users only * change variable names throughout after info on rauby/rails naming conventions, update tests for change in who can view codes only download link * rework csv service for readability, remove delegating methods from lettings log to keep all code to do with mapping between our domain and desired export format in one place * update test name * correct a small typo and remove a duplicated method after clever git merge conflict suggestion * point review app at staging csv bucket for csv download * change variables named codes_only_export to codes_only to avoid inconsistency * write tests to ensure that differetn user roles have the correct permissions around csv download * ensure that non support users may not download codes only exports * correct a small error in a previous commit * correct minor linting error
2 years ago
cf set-env $APP_NAME CSV_DOWNLOAD_PAAS_INSTANCE "dluhc-core-staging-csv-bucket"
cf set-env $APP_NAME SENTRY_DSN $SENTRY_DSN
cf set-env $APP_NAME APP_HOST "https://dluhc-core-review-${{ github.event.pull_request.number }}.london.cloudapps.digital"
- name: Bind postgres service
env:
APP_NAME: dluhc-core-review-${{ github.event.pull_request.number }}
SERVICE_NAME: dluhc-core-review-${{ github.event.pull_request.number }}-postgres
run: |
cf bind-service $APP_NAME $SERVICE_NAME --wait
- name: Bind redis service
env:
APP_NAME: dluhc-core-review-${{ github.event.pull_request.number }}
SERVICE_NAME: dluhc-core-review-${{ github.event.pull_request.number }}-redis
run: |
cf bind-service $APP_NAME $SERVICE_NAME --wait
- name: Bind logit drain service
env:
APP_NAME: dluhc-core-review-${{ github.event.pull_request.number }}
SERVICE_NAME: logit-ssl-drain
run: |
cf bind-service $APP_NAME $SERVICE_NAME --wait
- name: Bind S3 buckets services
env:
APP_NAME: dluhc-core-review-${{ github.event.pull_request.number }}
run: |
cf bind-service $APP_NAME dluhc-core-review-csv-bucket --wait
cf bind-service $APP_NAME dluhc-core-review-export-bucket --wait
cf bind-service $APP_NAME dluhc-core-review-import-bucket --wait
- name: Start review app
env:
APP_NAME: dluhc-core-review-${{ github.event.pull_request.number }}
run: |
cf restage $APP_NAME
- name: Comment on PR with URL
uses: unsplash/comment-on-pr@v1.3.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
msg: "Created review app at https://dluhc-core-review-${{ github.event.pull_request.number }}.london.cloudapps.digital"
check_for_duplicate_msg: true
duplicate_msg_pattern: Created review app at*