-
Notifications
You must be signed in to change notification settings - Fork 0
96 lines (84 loc) · 4.33 KB
/
Copy pathMetadata.yml
File metadata and controls
96 lines (84 loc) · 4.33 KB
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
# Display Name of the workflow
name: Calculate - Metadata
# Event listeners for when the job should start execution
on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Allow this workflow to be called from another workflow
workflow_call:
inputs:
correlationId:
description: 'Correlates the origin job with the child instance since process start does not return an ID.'
type: string
required: false
outputs:
channel:
description: 'The channel that the build should be published to.'
value: ${{ jobs.Deploy-Metadata.outputs.channel }}
environment:
description: 'The GitHub Environment that the build should use.'
value: ${{ jobs.Deploy-Metadata.outputs.environment }}
shortSha:
description: 'The first 7 characters of the SHA hash that represents the current commit that the build is operating off of.'
value: ${{ jobs.Deploy-Metadata.outputs.shortSha }}
version:
description: 'The version of the project that is being built.'
value: ${{ jobs.Deploy-Metadata.outputs.version }}
# Define each session of execution that should be executed
jobs:
# Calculates the tag and channel metadata based on the event that triggered the workflow, and making that data available to downstream jobs through outputs.
Deploy-Metadata:
# Human friendly display name for the job
name: Calculate - Metadata
# Operating system that the job will run on
runs-on: ubuntu-slim
# Sets the scopes available to the github_token injected to the GH Actions runner
permissions:
# Read the files in the repository to be able to compute the version from the package.json.
contents: read
# Set of data that will be made available to downstream jobs.
outputs:
channel: ${{ steps.computedChannel.outputs.channel }}
environment: ${{ steps.computedGitHubEnvironment.outputs.environment }}
shortSha: ${{ steps.shortSha.outputs.shortSha }}
version: ${{ steps.computedVersion.outputs.version }}
# Set of actions to perform for this execution sandbox
steps:
# Download the source code
- name: Checkout Files from Repo
uses: actions/checkout@v7
# Extract the project version from the package.json
- name: Extract Project Version
id: computedVersion
background: true
run: echo "version=$(npm pkg get version --workspaces=false | tr -d \")" >> "$GITHUB_OUTPUT"
# Set the experimental tag to indicate if it is an Alpha or Beta build
- name: Compute Channel
id: computedChannel
background: true
run: |
if [ "${{ github.event_name }}" = "release" ] && [ "${{ github.event.release.prerelease }}" = "true" ]; then
echo "channel=beta" >> "$GITHUB_OUTPUT"
elif [ "${{ github.event_name }}" = "release" ]; then
echo "channel=stable" >> "$GITHUB_OUTPUT"
else
echo "channel=alpha" >> "$GITHUB_OUTPUT"
fi
# Compute the GitHub Environment to be used by the deployment
- name: Compute GitHub Environment
id: computedGitHubEnvironment
background: true
run: |
if [ "${{ github.event_name }}" = "release" ]; then
echo "environment=Azure-Privileged" >> "$GITHUB_OUTPUT"
else
echo "environment=Azure-Alpha" >> "$GITHUB_OUTPUT"
fi
# Get the first 7 chars of the SHA hash that represents the current commit that the build is operating off of.
- name: Compute Short SHA - Experimental Channel
id: shortSha
background: true
run: echo "shortSha=$(echo ${{ github.sha }} | head -c 7)" >> "$GITHUB_OUTPUT"
# Bring job back to sync execution by awaiting for all async jobs to finish before continuing
- name: Steps - Convert Back To Synchronous Execution
wait-all: true