|
7 | 7 | name: Build |
8 | 8 |
|
9 | 9 | permissions: # Sets permissions of the GITHUB_TOKEN (Can be set at the workflow level or job level) |
10 | | - contents: read |
11 | | - # More info: https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#permissions |
| 10 | + contents: read |
| 11 | + # More info: https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#permissions |
12 | 12 |
|
13 | 13 | on: # Describes when to run the workflow |
14 | | - # https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows |
| 14 | + # https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows |
15 | 15 |
|
16 | | - workflow_dispatch: # When triggered manually |
| 16 | + workflow_dispatch: # When triggered manually |
17 | 17 |
|
18 | | - push: # On push to the following branches. Temporarily add a development branch to prompt workflow runs for troubleshooting |
19 | | - branches: ["main", "rc", "hotfix-rc"] |
20 | | - paths-ignore: # Updates to these directories or files will not trigger a workflow run |
21 | | - - ".github/workflows/**" |
| 18 | + push: # On push to the following branches. Temporarily add a development branch to prompt workflow runs for troubleshooting |
| 19 | + branches: ["main", "rc", "hotfix-rc"] |
| 20 | + paths-ignore: # Updates to these directories or files will not trigger a workflow run |
| 21 | + - ".github/workflows/**" |
22 | 22 |
|
23 | | - # Pull_request_target: #We strongly discourage using this unless absolutely necessary as it requires access to certain Github secrets. |
24 | | - # If using this, include the .github/workflows/check-run.yml job and target only the main branch |
25 | | - # More info at https://github.blog/news-insights/product-news/github-actions-improvements-for-fork-and-pull-request-workflows/#improvements-for-public-repository-forks |
| 23 | + # Pull_request_target: #We strongly discourage using this unless absolutely necessary as it requires access to certain Github secrets. |
| 24 | + # If using this, include the .github/workflows/check-run.yml job and target only the main branch |
| 25 | + # More info at https://github.blog/news-insights/product-news/github-actions-improvements-for-fork-and-pull-request-workflows/#improvements-for-public-repository-forks |
26 | 26 |
|
27 | | - pull_request: # When a pull request event occurs |
28 | | - types: |
29 | | - [ |
30 | | - opened, |
31 | | - synchronize, |
32 | | - unlabeled, |
33 | | - labeled, |
34 | | - unlabeled, |
35 | | - reopened, |
36 | | - edited, |
37 | | - ] |
38 | | - branches: ["main"] # Branches where a pull request will trigger the workflow |
| 27 | + pull_request: # When a pull request event occurs |
| 28 | + types: |
| 29 | + [opened, synchronize, unlabeled, labeled, unlabeled, reopened, edited] |
| 30 | + branches: ["main"] # Branches where a pull request will trigger the workflow |
39 | 31 |
|
40 | | - release: # Runs your workflow when release activity in your repository occurs |
41 | | - types: [published, created] |
| 32 | + release: # Runs your workflow when release activity in your repository occurs |
| 33 | + types: [published, created] |
42 | 34 |
|
43 | | - merge_group: # Runs required status checks on merge groups created by merge queue |
44 | | - types: [checks_requested] |
| 35 | + merge_group: # Runs required status checks on merge groups created by merge queue |
| 36 | + types: [checks_requested] |
45 | 37 |
|
46 | | - repository_dispatch: # Runs when a webook event triggers a workflow from outside of github |
47 | | - types: [contentful-publish] # Optional, limit repository dispatch events to those in a specified list |
| 38 | + repository_dispatch: # Runs when a webook event triggers a workflow from outside of github |
| 39 | + types: [contentful-publish] # Optional, limit repository dispatch events to those in a specified list |
48 | 40 |
|
49 | | - workflow_call: # Workflow can be called by another workflow |
| 41 | + workflow_call: # Workflow can be called by another workflow |
50 | 42 |
|
51 | 43 | env: # Environment variables set for this step but not accessible by all workflows, steps or jobs. |
52 | | - _AZ_REGISTRY: "ACMEprod.azurecr.io" |
53 | | - INCREMENTAL: "${{ contains(github.event_name, 'pull_request') && '--sast-incremental' || '' }}" |
| 44 | + _AZ_REGISTRY: "ACMEprod.azurecr.io" |
| 45 | + INCREMENTAL: "${{ contains(github.event_name, 'pull_request') && '--sast-incremental' || '' }}" |
54 | 46 |
|
55 | 47 | jobs: # A workflow run is made up of one or more jobs that can run sequentially or in parallel |
56 | | - first-job: |
57 | | - name: First Job Name |
58 | | - uses: ./.github/workflows/examples/example-references/_version.yml # Path to an existing github action |
59 | | - if: github.event.pull_request.draft == false # prevent part of a job from running on a draft PR |
60 | | - secrets: inherit # When called by another workflow, pass all the calling workflow's secrets to the called workflow |
61 | | - # "secrets" is only available for a reusable workflow call with "uses" |
62 | | - strategy: # Create multiple job runs for each of a set of variables |
63 | | - fail-fast: false # If true, cancel entire run if any job in the matrix fails |
64 | | - matrix: # Matrix of variables used to define multiple job runs |
65 | | - include: |
66 | | - - project_name: Admin |
67 | | - base_path: ./src |
68 | | - node: true # Enables steps with if: ${{ matrix.node }} |
69 | | - |
70 | | - # https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/controlling-permissions-for-github_token |
71 | | - permissions: # Sets permissions of the GITHUB_TOKEN |
72 | | - security-events: write # Allow actions to upload results to Github |
73 | | - id-token: write # Required to fetch an OpenID Connect (OIDC) token |
74 | | - contents: read # For actions/checkout to fetch code |
75 | | - deployments: write # Permits an action to create a new deployment |
76 | | - issues: write # Permits an action to create a new issue |
77 | | - checks: write # Permits an action to create a check run |
78 | | - actions: write # Permits an action to cancel a workflow run |
79 | | - packages: read # Permits an action to access packages on GitHub Packages |
80 | | - pull-requests: write # Permits an action to add a label to a pull request |
81 | | - |
82 | | - # steps: when a reusable workflow is called with "uses", "steps" is not available |
83 | | - second-job: |
84 | | - name: Second Job Name |
85 | | - runs-on: ubuntu-22.04 # The type of runner that the job will run on, not available if "uses" is used |
86 | | - permissions: |
87 | | - contents: read |
88 | | - id-token: write # Required to fetch an OpenID Connect (OIDC) token |
89 | | - defaults: |
90 | | - run: # Set the default shell and working directory |
91 | | - shell: bash |
92 | | - working-directory: "home/WorkingDirectory" |
93 | | - |
94 | | - needs: |
95 | | - - first-job # This job will wait until first-job completes |
96 | | - # https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/setting-a-default-shell-and-working-directory |
97 | | - steps: |
98 | | - # Using Azure go obtain secrets from Azure Key Vault |
99 | | - - name: Log in to Azure |
100 | | - uses: bitwarden/gh-actions/azure-login@main |
101 | | - with: |
102 | | - subscription_id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} |
103 | | - tenant_id: ${{ secrets.AZURE_TENANT_ID }} |
104 | | - client_id: ${{ secrets.AZURE_CLIENT_ID }} |
105 | | - |
106 | | - # Obtain the Key Vault secrets and use them later via GitHub outputs |
107 | | - - name: Get Azure Key Vault secrets |
108 | | - id: get-kv-secrets |
109 | | - uses: bitwarden/gh-actions/get-keyvault-secrets@main |
110 | | - with: |
111 | | - keyvault: gh-REPOSITORY_NAME_EXAMPLE # The name of the Azure Key Vault created for this repossitory |
112 | | - secrets: "SECRETS-OR-CREDENTIALS,ANOTHER-SECRET" # Comma-separated list of secrets to retrieve from Azure Key Vault |
113 | | - |
114 | | - # Logout to remove access to Azure Key Vault secrets |
115 | | - - name: Log out from Azure |
116 | | - uses: bitwarden/gh-actions/azure-logout@main |
117 | | - |
118 | | - - name: Descriptive step name |
119 | | - # NOT RECOMMENDED if: always() # run even if previous steps failed or the workflow is canceled, this can cause a workflow run to hang indefinitely |
120 | | - if: failure() # run when any previous step of a job fails |
121 | | - # if: '!cancelled()' # run even if previous steps failed |
122 | | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 Always pin a public action version to a full git SHA, followed by the version number in a comment. Version pins are insecure and can introduce vulnerabilities into workflows. |
123 | | - with: # Parameters specific to this action that need to be defined in order for the step to be completed |
124 | | - fetch-depth: 0 # Full git history for actions that rely on whether a change has occurred |
125 | | - ref: ${{ github.event.pull_request.head.sha }} |
126 | | - creds: ${{ steps.get-kv-secrets.outputs.SECRETS-OR-CREDENTIALS }} # Use the secrets retrieved from Azure Key Vault in the previous step |
127 | | - - name: Another descriptive step name |
128 | | - # Run a script instead of an existing github action |
129 | | - run: | |
130 | | - whoami |
131 | | - dotnet --info |
132 | | - node --version |
133 | | - npm --version |
134 | | - echo "GitHub ref: $GITHUB_REF" |
135 | | - echo "GitHub event: $GITHUB_EVENT" |
| 48 | + first-job: |
| 49 | + name: First Job Name |
| 50 | + uses: ./.github/workflows/examples/example-references/_version.yml # Path to an existing github action |
| 51 | + if: github.event.pull_request.draft == false # prevent part of a job from running on a draft PR |
| 52 | + strategy: # Create multiple job runs for each of a set of variables |
| 53 | + fail-fast: false # If true, cancel entire run if any job in the matrix fails |
| 54 | + matrix: # Matrix of variables used to define multiple job runs |
| 55 | + include: |
| 56 | + - project_name: Admin |
| 57 | + base_path: ./src |
| 58 | + node: true # Enables steps with if: ${{ matrix.node }} |
| 59 | + |
| 60 | + # https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/controlling-permissions-for-github_token |
| 61 | + permissions: # Sets permissions of the GITHUB_TOKEN |
| 62 | + security-events: write # Allow actions to upload results to Github |
| 63 | + id-token: write # Required to fetch an OpenID Connect (OIDC) token |
| 64 | + contents: read # For actions/checkout to fetch code |
| 65 | + deployments: write # Permits an action to create a new deployment |
| 66 | + issues: write # Permits an action to create a new issue |
| 67 | + checks: write # Permits an action to create a check run |
| 68 | + actions: write # Permits an action to cancel a workflow run |
| 69 | + packages: read # Permits an action to access packages on GitHub Packages |
| 70 | + pull-requests: write # Permits an action to add a label to a pull request |
| 71 | + |
| 72 | + # steps: when a reusable workflow is called with "uses", "steps" is not available |
| 73 | + second-job: |
| 74 | + name: Second Job Name |
| 75 | + runs-on: ubuntu-22.04 # The type of runner that the job will run on, not available if "uses" is used |
| 76 | + permissions: |
| 77 | + contents: read |
| 78 | + id-token: write # Required to fetch an OpenID Connect (OIDC) token |
| 79 | + defaults: |
| 80 | + run: # Set the default shell and working directory |
| 81 | + shell: bash |
| 82 | + working-directory: "home/WorkingDirectory" |
| 83 | + |
| 84 | + needs: |
| 85 | + - first-job # This job will wait until first-job completes |
| 86 | + # https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/setting-a-default-shell-and-working-directory |
| 87 | + steps: |
| 88 | + # Using Azure go obtain secrets from Azure Key Vault |
| 89 | + - name: Log in to Azure |
| 90 | + uses: bitwarden/gh-actions/azure-login@main |
| 91 | + with: |
| 92 | + subscription_id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} |
| 93 | + tenant_id: ${{ secrets.AZURE_TENANT_ID }} |
| 94 | + client_id: ${{ secrets.AZURE_CLIENT_ID }} |
| 95 | + |
| 96 | + # Obtain the Key Vault secrets and use them later via GitHub outputs |
| 97 | + - name: Get Azure Key Vault secrets |
| 98 | + id: get-kv-secrets |
| 99 | + uses: bitwarden/gh-actions/get-keyvault-secrets@main |
| 100 | + with: |
| 101 | + keyvault: gh-REPOSITORY_NAME_EXAMPLE # The name of the Azure Key Vault created for this repossitory |
| 102 | + secrets: "SECRETS-OR-CREDENTIALS,ANOTHER-SECRET" # Comma-separated list of secrets to retrieve from Azure Key Vault |
| 103 | + |
| 104 | + # Logout to remove access to Azure Key Vault secrets |
| 105 | + - name: Log out from Azure |
| 106 | + uses: bitwarden/gh-actions/azure-logout@main |
| 107 | + |
| 108 | + - name: Descriptive step name |
| 109 | + # NOT RECOMMENDED if: always() # run even if previous steps failed or the workflow is canceled, this can cause a workflow run to hang indefinitely |
| 110 | + if: failure() # run when any previous step of a job fails |
| 111 | + # if: '!cancelled()' # run even if previous steps failed |
| 112 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 Always pin a public action version to a full git SHA, followed by the version number in a comment. Version pins are insecure and can introduce vulnerabilities into workflows. |
| 113 | + with: # Parameters specific to this action that need to be defined in order for the step to be completed |
| 114 | + persist-credentials: false # Do not persist the token used to fetch the repository, more secure |
| 115 | + fetch-depth: 0 # Full git history for actions that rely on whether a change has occurred |
| 116 | + ref: ${{ github.event.pull_request.head.sha }} |
| 117 | + creds: ${{ steps.get-kv-secrets.outputs.SECRETS-OR-CREDENTIALS }} # Use the secrets retrieved from Azure Key Vault in the previous step |
| 118 | + - name: Another descriptive step name |
| 119 | + # Run a script instead of an existing github action |
| 120 | + run: | |
| 121 | + whoami |
| 122 | + dotnet --info |
| 123 | + node --version |
| 124 | + npm --version |
| 125 | + echo "GitHub ref: $GITHUB_REF" |
| 126 | + echo "GitHub event: $GITHUB_EVENT" |
0 commit comments