Skip to content

Commit

Permalink
PXBF-main: Merge branch 'main' of github.com:GSA/px-benefit-finder
Browse files Browse the repository at this point in the history
  • Loading branch information
scottqueen-bixal committed May 2, 2024
2 parents b7224b2 + 84b56aa commit b4db0e5
Show file tree
Hide file tree
Showing 125 changed files with 24,915 additions and 18,588 deletions.
350 changes: 0 additions & 350 deletions .circleci/config.yml

This file was deleted.

201 changes: 201 additions & 0 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
name: Build and deploy

on:
push:
branches:
- dev
- main

jobs:
php-lint:
name: PHP Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Nodejs
uses: actions/setup-node@v4
with:
node-version-file: "./benefit-finder/package.json"
- name: Set env.BRANCH
run: |
echo "BRANCH=$(echo $GITHUB_REF | cut -d'/' -f 3)" >> $GITHUB_ENV
- name: Install PHP
run: bash ./scripts/pipeline/deb-php-install.sh
# - name: Install Node.js
# run: |
# bash ./scripts/pipeline/deb-nodejs-install.sh
- name: Init submodule
run: |
git submodule init
git submodule update
cd usagov-2021
git checkout prod
cd ..
- name: Install Linters and Sniffers
run: |
npm install --prefix ./benefit-finder
composer global config --no-plugins allow-plugins.dealerdirect/phpcodesniffer-composer-installer false
composer global require --dev drupal/coder php-parallel-lint/php-parallel-lint squizlabs/php_codesniffer=*
COMPOSER_DIR=$(composer -n config --global home)
$COMPOSER_DIR/vendor/bin/phpcs --config-set installed_paths $COMPOSER_DIR/vendor/drupal/coder/coder_sniffer,$COMPOSER_DIR/vendor/sirbrillig/phpcs-variable-analysis,$COMPOSER_DIR/vendor/slevomat/coding-standard
mkdir -p /tmp/results
touch /tmp/results/php-lint.log
touch /tmp/results/php-cs.log
touch /tmp/results/theme-lint.log
- name: PHP Lint
run: |
COMPOSER_DIR=$(composer -n config --global home)
$COMPOSER_DIR/vendor/bin/parallel-lint -e php,module,inc,install,test,profile,theme ./benefit-finder ./benefit-finder # | tee /tmp/results/php-lint.log
- name: PHP CodeSniff (Ignore warnings)
run: |
COMPOSER_DIR=$(composer -n config --global home)
$COMPOSER_DIR/vendor/bin/phpcs --standard=./usagov-2021/.phpcs.xml.dist -v --warning-severity=0 ./usagov_benefit_finder # | tee /tmp/results/php-cs.log
backup-database:
needs: php-lint
uses: ./.github/workflows/database-backup.yml
secrets: inherit
component-library:
needs: backup-database
name: Build and deploy component library
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Nodejs
uses: actions/setup-node@v4
with:
node-version-file: "./benefit-finder/package.json"
- name: Set env.BRANCH
run: |
echo "BRANCH=$(echo $GITHUB_REF | cut -d'/' -f 3)" >> $GITHUB_ENV
- name: Install basic dependancies
run: |
./scripts/pipeline/deb-basic-deps.sh
- name: Install Cloudfoundry CLI
run: ./scripts/pipeline/deb-cf-install.sh
- name: Init submodule
run: |
git submodule init
git submodule update
cd usagov-2021
git checkout prod
cd ..
- name: Deploy Storybook
env:
CF_USER: '${{ secrets.CF_USER }}'
CF_PASSWORD: '${{ secrets.CF_PASSWORD }}'
CF_ORG: '${{ secrets.CF_ORG }}'
PROJECT: '${{ secrets.PROJECT }}'
run: |
source ./scripts/pipeline/cloud-gov-login.sh
cd benefit-finder
mv manifest.yml manifest.yml.tpl
envsubst < manifest.yml.tpl > manifest.yml
npm ci
npm run build:storybook
mv manifest.yml storybook-static/
mv Staticfile storybook-static/
mv nginx storybook-static/
cd storybook-static
echo "${{ secrets.STORYBOOK_USERNAME }}:${{ secrets.STORYBOOK_PASSWORD }}" > Staticfile.auth
cf push benefit-finder-storybook-${BRANCH}
build-and-deploy:
needs: backup-database
name: Build and deploy
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Nodejs
uses: actions/setup-node@v4
with:
node-version-file: "./benefit-finder/package.json"
- name: Set env.BRANCH
run: |
echo "BRANCH=$(echo $GITHUB_REF | cut -d'/' -f 3)" >> $GITHUB_ENV
- name: Install basic dependancies
run: ./scripts/pipeline/deb-basic-deps.sh
- name: Install Cloudfoundry CLI
run: ./scripts/pipeline/deb-cf-install.sh
- name: Init submodule
run: |
git submodule init
git submodule update
cd usagov-2021
git checkout prod
- name: Merge files into module
run: |
bash ./scripts/pipeline/mv-benefit-finder-app.sh
rm -r usagov-2021/web/modules/custom/usagov_benefit_finder/*
mv usagov_benefit_finder/* usagov-2021/web/modules/custom/usagov_benefit_finder/
mv ./scripts/application/* usagov-2021/scripts/
- name: Configure application
run: |
cd usagov-2021
sed -i "s/memory_limit = 1G/memory_limit = 500M/g" .docker/src-cms/etc/php81/php.ini
mv .docker/Dockerfile-cms .
sed -i 's/80/8080/g' Dockerfile-cms
sed -i 's/ENTRYPOINT/CMD/' Dockerfile-cms
sed -i 's/\["s3"\]\[\]?/s3\[\]/g' scripts/tome-run.sh scripts/tome-sync.sh
sed -i 's/80/8080/g' .docker/src-cms/etc/nginx/partials/cms.conf.tmpl
sed -i "s/\$service\['name'\] === 'database'/stristr(\$service\['name'\], 'mysql')/" web/sites/default/settings.php
sed -i "s/\$settings\['hash_salt'\] = \$service\['credentials'\]\['HASH_SALT'\]/\$settings\['hash_salt'\] = \$service\['credentials'\]\['hash_salt'\]/" web/sites/default/settings.php
sed -i "s/\$service\['name'\] === 'storage'/stristr(\$service\['name'\], 'storage')/" web/sites/default/settings.php
sed -i "s/\$service\['name'\] === 'secrets'/stristr(\$service\['name'\], 'secrets')/" web/sites/default/settings.php
- name: Docker login
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ secrets.CR_USERNAME }}
password: ${{ secrets.CR_PAT }}
- name: Docker tag
id: meta
uses: docker/[email protected]
with:
images: ghcr.io/${{ vars.CR_REPOSITORY }}
tags: |
type=sha,enable=true,priority=100,prefix=,suffix=,format=short
- name: Build and push Docker image
uses: docker/[email protected]
with:
context: ./usagov-2021
file: ./usagov-2021/Dockerfile-cms
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Configure manifest.yml
env:
PROJECT: '${{ secrets.PROJECT }}'
run: |
declare MEMORY
[ "${BRANCH}" = "dev" ] && MEMORY=${{ vars.CMS_MEMORY_DEV }}
[ "${BRANCH}" = "main" ] && MEMORY=${{ vars.CMS_MEMORY_MAIN }}
cd usagov-2021
sed -i "s#^ image: .*cms-latest*# image: ghcr.io/${{ vars.CR_REPOSITORY }}:${{ steps.meta.outputs.tags }}#" manifest.yml
sed -i "s#^ - secauthsecrets##" manifest.yml
sed -i "s#- name: cms#- name: ${PROJECT}-cms-${BRANCH}#" manifest.yml
sed -i "s#^ memory: 1.5G# memory: ${MEMORY}#" manifest.yml
sed -i "s#^ - database# - ${PROJECT}-mysql-${BRANCH}#" manifest.yml
sed -i "s#^ - secrets# - ${PROJECT}-secrets-${BRANCH}#" manifest.yml
sed -i "s#^ - storage# - ${PROJECT}-storage-${BRANCH}#" manifest.yml
sed -i "s#^ - dbstorage# - ${PROJECT}-static-${BRANCH}#" manifest.yml
sed -i '16i\ command: /var/www/scripts/entrypoint.sh' manifest.yml
- name: Deploy application
env:
CF_USER: '${{ secrets.CF_USER }}'
CF_PASSWORD: '${{ secrets.CF_PASSWORD }}'
CF_ORG: '${{ secrets.CF_ORG }}'
CR_PAT: '${{ secrets.CR_PAT }}'
CR_USERNAME: '${{ secrets.CR_USERNAME }}'
PROJECT: '${{ secrets.PROJECT }}'
run: |
source ./scripts/pipeline/cloud-gov-login.sh
cd usagov-2021
cf delete ${PROJECT}-cms-${BRANCH} -f
CF_DOCKER_PASSWORD=${CR_PAT} cf push ${PROJECT}-cms-${BRANCH} --docker-image "${{ steps.meta.outputs.tags }}" --docker-username "${CF_USER}" && docker logout
../scripts/pipeline/cloud-gov-wait-for-application.sh ${PROJECT}-cms-${BRANCH}
cf add-network-policy ${PROJECT}-waf-${BRANCH} ${PROJECT}-cms-${BRANCH} -s ${PROJECT}-${BRANCH} -o ${CF_ORG} --protocol tcp --port 61443
cf map-route benefit-finder-cms-${BRANCH} apps.internal --hostname benefit-finder-cms-${BRANCH} --app-protocol http1
cd ..
source ./scripts/pipeline/cloud-gov-post-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Install basic dependancies
run: ./scripts/pipeline/deb-basic.deps.sh
run: ./scripts/pipeline/deb-basic-deps.sh
- name: Install Cloudfoundry CLI
run: ./scripts/pipeline/deb-cf-install.sh
- name: Cleanup keys (dev)
Expand All @@ -31,7 +31,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Install basic dependancies
run: ./scripts/pipeline/deb-basic.deps.sh
run: ./scripts/pipeline/deb-basic-deps.sh
- name: Install Cloudfoundry CLI
run: ./scripts/pipeline/deb-cf-install.sh
- name: Cleanup keys (main)
Expand Down
46 changes: 0 additions & 46 deletions .github/workflows/cypress.yml

This file was deleted.

36 changes: 0 additions & 36 deletions .github/workflows/database-backup-main.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,20 +1,31 @@
name: Database backup (dev)
name: Database backup

on:
push:
branches:
- dev
workflow_call:
secrets:
CF_USER:
required: true
CF_PASSWORD:
required: true
CF_ORG:
required: true
PROJECT:
required: true
schedule:
- cron: '0 0 * * *'

jobs:
backup-database-dev:
backup-database:
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set env.BRANCH
run: |
echo "BRANCH=$(echo $GITHUB_REF | cut -d'/' -f 3)" >> $GITHUB_ENV
- name: Install basic dependancies
run: ./scripts/pipeline/deb-basic.deps.sh
run: ./scripts/pipeline/deb-basic-deps.sh
- name: Install AWSCLI
run: ./scripts/pipeline/awscli-install.sh
- name: Install MySQL Client
Expand All @@ -27,10 +38,9 @@ jobs:
CF_USER: '${{ secrets.CF_USER }}'
CF_PASSWORD: '${{ secrets.CF_PASSWORD }}'
CF_ORG: '${{ secrets.CF_ORG }}'
project: '${{ secrets.project }}'
PROJECT: '${{ secrets.PROJECT }}'
run: |
export TIMESTAMP=$(date --utc +%FT%TZ | tr ':', '-')
export ENVIRONMENT=dev
source ./scripts/pipeline/cloud-gov-login.sh
source ./scripts/pipeline/database-backup.sh
source ./scripts/pipeline/s3-backup-upload.sh
9 changes: 6 additions & 3 deletions .github/workflows/database-restore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set env.BRANCH
run: |
echo "BRANCH=$(echo $GITHUB_REF | cut -d'/' -f 3)" >> $GITHUB_ENV
- name: Install basic dependancies
run: ./scripts/pipeline/deb-basic.deps.sh
run: ./scripts/pipeline/deb-basic-deps.sh
- name: Install AWSCLI
run: ./scripts/pipeline/awscli-install.sh
- name: Install MySQL Client
Expand All @@ -28,11 +31,11 @@ jobs:
CF_USER: '${{ secrets.CF_USER }}'
CF_PASSWORD: '${{ secrets.CF_PASSWORD }}'
CF_ORG: '${{ secrets.CF_ORG }}'
project: '${{ secrets.project }}'
PROJECT: '${{ secrets.PROJECT }}'
run: |
export ENVIRONMENT='${{ github.ref_name }}'
export S3_FILE_PATH=${{ github.event.inputs.database_file_override }}
source ./scripts/pipeline/cloud-gov-login.sh
source ./scripts/pipeline/s3-backup-download.sh
source ./scripts/pipeline/database-restore.sh
source ./scripts/pipeline/cloud-gov-post-deploy.sh
source ./scripts/pipeline/s3-backup-post-restore.sh
File renamed without changes.
Loading

0 comments on commit b4db0e5

Please sign in to comment.