forked from eclipse-edc/MinimumViableDataspace
-
Notifications
You must be signed in to change notification settings - Fork 10
49 lines (43 loc) · 1.71 KB
/
cd.yaml
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
name: CD
on:
pull_request:
branches: [ main ]
paths-ignore:
- 'docs/**'
# Grant permissions to obtain federated identity credentials
# see https://docs.github.com/actions/deployment/security-hardening-your-deployments/configuring-openid-connect-in-azure
permissions:
id-token: write
contents: read
# Update this value with a unique name to guarantee uniqueness of resource names and avoid conflicts between fork repositories when running CD workflow.
# CD workflow creates resources with this prefix and destroy them.
env:
CD_RESOURCES_PREFIX: mvd
jobs:
# The purpose of this job is only to set up resources_prefix as an output, because env context is not available in arguments to a called workflow
# See this discussion for more context: https://github.community/t/reusable-workflow-env-context-not-available-in-jobs-job-id-with/206111/13
SetResourcesPrefix:
name: 'Set Resources Prefix'
runs-on: ubuntu-latest
# Added a step doing nothing, because a job needs to have at least one step.
steps:
- name: 'Empty step.'
run: exit 0
outputs:
resources_prefix: ${{ env.CD_RESOURCES_PREFIX }}${{ github.run_number }}
Deploy:
uses: ./.github/workflows/deploy.yaml
secrets: inherit
needs: SetResourcesPrefix
with:
resources_prefix: ${{ needs.SetResourcesPrefix.outputs.resources_prefix }}
Destroy:
# Always run Destroy workflow unless SetResourcesPrefix workflow fails.
if: ${{ always() && needs.SetResourcesPrefix.result == 'success'}}
uses: ./.github/workflows/destroy.yaml
needs:
- SetResourcesPrefix
- Deploy
secrets: inherit
with:
resources_prefix: ${{ needs.SetResourcesPrefix.outputs.resources_prefix }}