Merge pull request #2927 from OfficeForProductSafetyAndStandards/api/… #19
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy to API Test | |
on: | |
push: | |
branches: | |
- api-test | |
jobs: | |
deploy: | |
name: Deploy to API Test | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install cf client | |
env: | |
CF_CLI_VERSION: v7 | |
run: | | |
mkdir -p $GITHUB_WORKSPACE/bin | |
curl -A "" -L "https://packages.cloudfoundry.org/stable?release=linux64-binary&version=${CF_CLI_VERSION}" | tar -zx -C $GITHUB_WORKSPACE/bin | |
echo "$GITHUB_WORKSPACE/bin" >> $GITHUB_PATH | |
- name: Create GitHub deployment for API Test | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
BRANCH: main | |
run: | | |
source deploy-github-functions.sh | |
gh_deploy_create api-test | |
- name: Initiate APi Test deployment status | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
source deploy-github-functions.sh | |
# URL where the deployment progress can be tracked. Exported for future steps. | |
log_url=$(echo "https://github.com/$GITHUB_REPOSITORY/actions?query=branch%3Amain+workflow%3ADeploy+api-test") | |
echo "LOG_URL=$log_url" >> $GITHUB_ENV | |
gh_deploy_initiate api-test $log_url | |
- name: Deploy to API Test | |
env: | |
SPACE: sandbox | |
APP_NAME: psd-web | |
DOMAIN: api-test.product-safety-database.service.gov.uk | |
DOMAIN_SUPPORT: api-test-support.product-safety-database.service.gov.uk | |
DOMAIN_REPORT: api-test-report.product-safety-database.service.gov.uk | |
WEB_DISK_QUOTA: 2.5G | |
WORKER_DISK_QUOTA: 2.5G | |
WEB_MEMORY: 2G | |
WORKER_MEMORY: 1G | |
WEB_INSTANCES: 1 | |
WORKER_INSTANCES: 1 | |
WEB_MAX_THREADS: 5 | |
WORKER_MAX_THREADS: 10 | |
CF_USERNAME: ${{ secrets.PaaSUsernameInt }} | |
CF_PASSWORD: ${{ secrets.PaaSPasswordInt }} | |
SENTRY_SERVICE_NAME: psd-api-test-sentry-env | |
run: | | |
cf api api.london.cloud.service.gov.uk | |
cf auth | |
cf target -o 'beis-opss' -s $SPACE | |
chmod +x ./deploy.sh | |
./deploy.sh | |
cf logout | |
- name: Update API Test deployment status (success) | |
if: success() | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
source deploy-github-functions.sh | |
environment_url=https://api-test.product-safety-database.service.gov.uk/ | |
gh_deploy_success api-test $LOG_URL $environment_url | |
- name: Update API Test deployment status (failure) | |
if: failure() | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
source deploy-github-functions.sh | |
gh_deploy_failure api-test $LOG_URL | |
- name: Set up Ruby | |
if: success() | |
uses: ruby/setup-ruby@v1 | |
- uses: actions/cache@v3 | |
with: | |
path: vendor/bundle | |
key: ${{ runner.os }}-gems-no-dev-${{ hashFiles('**/Gemfile.lock') }} | |
restore-keys: | | |
${{ runner.os }}-gems- | |
- name: Install RubyGems | |
if: success() | |
run: | | |
gem install bundler --no-doc | |
bundle config path vendor/bundle | |
bundle check || bundle install --without development --jobs=4 --retry=3 | |
- name: Alert team via Slack of deployment failure | |
if: failure() | |
env: | |
SLACK_WEBHOOK: ${{ secrets.SlackWebhookUrl }} | |
run: | | |
curl -X POST --data-urlencode "payload={\"channel\": \"#alerts\", \"username\": \"deploybot\", \"text\": \"Deploy has failed!\n\nSee $LOG_URL\", \"icon_emoji\": \":fire:\"}" $SLACK_WEBHOOK |