-
Notifications
You must be signed in to change notification settings - Fork 5
110 lines (95 loc) · 3.42 KB
/
deploy-api-test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
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