-
Notifications
You must be signed in to change notification settings - Fork 109
82 lines (79 loc) · 2.88 KB
/
deploy-template.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
---
name: Publish & Deploy Template
on: # yamllint disable-line rule:truthy
workflow_call:
inputs:
environ:
required: true
type: string
app_url:
required: true
type: string
app_names:
required: true
type: string
secrets:
CF_SERVICE_USER:
required: true
CF_SERVICE_AUTH:
required: true
ADD_TO_PROJECT_PAT:
required: true
jobs:
deploy:
name: deploy (${{ inputs.environ }})
environment: ${{ inputs.environ }}
runs-on: ubuntu-latest
permissions:
actions: write
strategy:
fail-fast: false
matrix: ${{ fromJSON(inputs.app_names) }}
steps:
- name: checkout
uses: actions/checkout@v4
- name: checkout datagov
uses: actions/checkout@v4
with:
repository: gsa/data.gov
path: "./datagov"
- name: Cancel Older Versions
run: |
readarray -t ids < <(curl -L -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" "https://api.github.com/repos/${{ github.repository }}/actions/workflows/publish.yml/runs" |jq '.workflow_runs[] | select(.status=="in_progress") | .id');
for id in "${ids[@]}"; do
if [[ "$id" != "${{ github.run_id }}" ]]; then
curl -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" -H "X-GitHub-Api-Version: 2022-11-28" "https://api.github.com/repos/${{ github.repository }}/actions/runs/$id/cancel";
fi
done;
- name: Modify robots.txt in dev
if: ${{ matrix.robots-dev && inputs.environ == 'development' }}
run: |
cp proxy/public/robots.develop.txt proxy/public/robots.txt
- name: deploy ${{ matrix.app }}
uses: cloud-gov/cg-cli-tools@main
with:
command: datagov/bin/check-and-renew ${{ matrix.app }} deploy ${{ inputs.environ }} --wait
cf_org: gsa-datagov
cf_space: ${{ inputs.environ }}
cf_username: ${{secrets.CF_SERVICE_USER}}
cf_password: ${{secrets.CF_SERVICE_AUTH}}
- name: smoke test
if: ${{ matrix.smoketest }}
run: |
sleep 10
curl --fail --silent ${{ inputs.app_url }}\
/api/action/status_show?$(date +%s)
- name: Create Issue if it fails 😢
if: ${{ failure() && github.ref == 'refs/heads/main' }}
uses: JasonEtco/create-an-issue@v2
env:
GITHUB_TOKEN: ${{ secrets.ADD_TO_PROJECT_PAT }}
GITHUB_JOB: ${{ toJson(github)['job'] }}
GITHUB_ATTEMPTS: ${{ github.run_attempt }}
LAST_COMMIT: ${{ github.sha }}
LAST_RUN_BY: ${{ github.actor }}
RUN_ID: ${{ github.run_id }}
REPO: ${{ github.repository }}
with:
filename: datagov/.github/deploy_failure.md
update_existing: true