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.
177 lines
12 KiB
177 lines
12 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 |
|
|
|
env: |
|
CLOUDFOUNDRY_KEY_BASE64: LS0tLS1CRUdJTiBQR1AgUFVCTElDIEtFWSBCTE9DSy0tLS0tCgptUUlOQkZ1YXFiMEJFQURQSGlOeUFGNFhuZUNOTGN1c210dzNTTHlLaGhNbTgzNm9WOVBhSk4xUkE2emFxbFlqCmFDZUYyVDhCcmd2a2MwSXNxTzdCUVBQZW53M0RnZWZKNG1NR2tCTHRhODJwcGNDYkRCaFo2bXpRV3V2bmZhRGgKZ3JmdE5obVoyY09PSkdkNE5TdVdUYWQ0bkZiL1lESkJuVTB0UXc4cW5jYlVrd3RQbGZ5MkRjaXd3SHpNZFJGYwpWSnlWVjY5S2orWDVTUWhlZDBQSFdOTG1yVVRHOGw3MVpUMVhPTWZmekFURHFRN2JaTFlobExCOVFWVEx0UUJFCm9nU1pndXVZNXhHZStDZnE2SWJPaHVtMjFpTkxnKzJ0RGxldkdrV0RCWFFDU29kZFlyY2ZOM0t2R0NOZW5vclMKNEQ0VHp5M1Ric0p4eWcxM1YwYWc1c1lWYnBCZ3hzeFVsSXJLcE1uWjNHUDEvclRyVXY5MWxmbFIrWlpqanNqYwpnS2VnNHEwUWh3M291L2xlL2lkSERkNXlxZ3NidjIwZXc3dkxyelZucEdZanZHMHk4bEZ1MlFQRDl6alRvKzVMCnFWS0RCL0JZWi9zOUxybzhGZ1dleFlxTkZXSHhBUVk1Y28vbVlldkFIM3VHNzVDNTRXV2t3RWgyRjlYRHNMbEIKRWFYeXdDMGs2Q09rb3RHdit1V29HWWtUeUF2eWYydkE0TGFRMURVZWJHT3dyTEJpY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Z09HSVFZd1VOVmF2NUJVZVZOc0Y3VXNMR2p4TlNRR0h3eG5aRE14dWd4VjBNb1orR0oxaTBvVEdyCnc2Z3FjVCsyMWhoSzlUY1ZsdnQ5UkNZejlCZG5YQjFSRzd2TWdpdEY2LzhEUTVRY29SOEcrb0xsZ1A0RUVmWDUKUTJSWGJyMGVrNkNvTERYRnhYM0xwV0xRTXpRZjdXZThtenlyZGlUd2dMTnAxUT09Cj1YeDdkCi0tLS0tRU5EIFBHUCBQVUJMSUMgS0VZIEJMT0NLLS0tLS0K |
|
|
|
jobs: |
|
postgres: |
|
name: Provision postgres |
|
runs-on: ubuntu-latest |
|
environment: staging |
|
|
|
steps: |
|
- name: Install Cloud Foundry CLI |
|
run: | |
|
echo $CLOUDFOUNDRY_KEY_BASE64 | base64 -d | 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: | |
|
echo $CLOUDFOUNDRY_KEY_BASE64 | base64 -d | 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: | |
|
echo $CLOUDFOUNDRY_KEY_BASE64 | base64 -d | 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 }} |
|
OS_DATA_KEY: ${{ secrets.OS_DATA_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 OS_DATA_KEY $OS_DATA_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 |
|
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*
|
|
|