-
Notifications
You must be signed in to change notification settings - Fork 1
133 lines (119 loc) · 4.12 KB
/
workflow-pull-request-path.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
name: "[Workflow] Pull request to branch"
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
on:
pull_request:
branches:
- main
permissions:
id-token: write
contents: write
security-events: write
pull-requests: read
actions: none
checks: none
deployments: none
issues: none
packages: none
repository-projects: none
statuses: none
defaults:
run:
shell: bash
jobs:
workflow_variables:
runs-on: ubuntu-latest
name: output workflow variables
outputs:
parsed_branch: ${{ steps.variables.outputs.branch_formatted }}
build_identifier: ${{ steps.variables.outputs.build_identifier }}
version_tag: ${{ steps.semver_tag.outputs.created_tag }}
steps:
- uses: actions/checkout@cbb722410c2e876e24abbe8de2cc27693e501dcb # pin@v3
- name: extract variables for workflow
id: variables
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
export BRANCH=$(echo ${GITHUB_HEAD_REF:-${GITHUB_REF##*/}} | awk -F'_' '{print $1}' | tr -cd '[:alnum:]' | tr '[:upper:]' '[:lower:]' | cut -c1-8)
echo "branch_formatted=$(echo ${BRANCH})" >> $GITHUB_OUTPUT
echo "build_identifier=$(echo ${BRANCH}${PR_NUMBER})" >> $GITHUB_OUTPUT
echo ${build_identifier}
- name: generate semver tag and release
id: semver_tag
uses: ministryofjustice/opg-github-actions/.github/actions/[email protected]
with:
prerelease: true
default_bump: "minor"
- uses: actions/labeler@main
if: github.event_name == 'pull_request'
with:
configuration-path: .github/labeller.yml
repo-token: ${{ secrets.GITHUB_TOKEN }}
sync-labels: true
unit_test_frontend:
name: Unit tests on Frontend app
uses: ./.github/workflows/_tests-frontend.yml
build_scan_push_containers:
name: Docker Build, Scan and Push
uses: ./.github/workflows/_build-push.yml
needs: [workflow_variables]
with:
tag: ${{ needs.workflow_variables.outputs.version_tag }}
branch_name: ${{ needs.workflow_variables.outputs.build_identifier }}
secrets: inherit
deploy_to_branch_environment:
name: Deploy to Branch Environment
needs: [
workflow_variables,
build_scan_push_containers,
unit_test_frontend
]
uses: ./.github/workflows/_deploy-infrastructure.yml
with:
workspace: ${{ needs.workflow_variables.outputs.build_identifier }}
account_name: development
container_version: ${{ needs.workflow_variables.outputs.version_tag }}
terraform_path: environment
apply: true
secrets: inherit
plan_development_account:
name: Plan against development account
needs: [
workflow_variables,
build_scan_push_containers,
]
uses: ./.github/workflows/_deploy-infrastructure.yml
with:
workspace: development
account_name: development
container_version: ${{ needs.workflow_variables.outputs.version_tag }}
terraform_path: account
apply: false
secrets: inherit
behat_branch_environment:
name: Branch Environment Behat
uses: ./.github/workflows/_tests-behat.yml
needs: [workflow_variables,deploy_to_branch_environment]
with:
workspace_name: ${{ needs.workflow_variables.outputs.build_identifier }}
version_tag: ${{ needs.workflow_variables.outputs.version_tag }}
base_url: ${{ needs.workflow_variables.outputs.build_identifier }}.serve.opg.service.justice.gov.uk
sirius_api_bucket: opg-backoffice-public-api-integration
suite: --suite=local
account_name: development
account_id: 705467933182
secrets: inherit
end_of_pr_workflow:
name: End of PR Workflow
runs-on: ubuntu-latest
needs: [workflow_variables,behat_branch_environment]
if: ${{ always() }}
steps:
- name: Check workflow result
if: ${{ failure() }}
run: |
echo "A job failed. Marking end-workflow as failed."
exit 1
- name: End of PR Workflow
run: echo "${{ needs.workflow_variables.outputs.version_tag }} tested, built and deployed to Development"