forked from nrwl/nx-set-shas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
68 lines (63 loc) · 3.19 KB
/
action.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
name: "Nx set SHAs"
description: "Derives SHAs for base and head for use in nx affected commands, optionally setting them as env variables for the current job"
inputs:
main-branch-name:
description: "The name of the main branch in your repo, used as the target of PRs. E.g. main, master etc"
default: "main"
set-environment-variables-for-job:
description: "Applies the derived SHAs for base and head as NX_BASE and NX_HEAD environment variables within the current Job"
default: "true"
error-on-no-successful-workflow:
description: "By default, if no successful workflow is found on the main branch to determine the SHA, we will log a warning and use HEAD~1. Enable this option to error and exit instead."
default: "false"
last-successful-event:
description: "The type of event to check for the last successful commit corresponding to that workflow-id, e.g. push, pull_request, release etc"
default: "push"
working-directory:
description: "The directory where your repository is located"
default: "."
workflow-id:
description: "The ID of the workflow to track or name of the file name. E.g. ci.yml. Defaults to current workflow"
outputs:
base:
description: The value intended for use with --base or NX_BASE in all subsequent `nx affected` commands within the current workflow
value: ${{ steps.setSHAs.outputs.base }}
head:
description: The value intended for use with --head or NX_HEAD in all subsequent `nx affected` commands within the current workflow
value: ${{ steps.setSHAs.outputs.head }}
noPreviousBuild:
description: "Used to check if a previous run was found in order to perform additional logic later on in your workflow, the only possible values is the string 'true', otherwise it won't be set"
value: ${{ steps.setSHAs.outputs.noPreviousBuild }}
runs:
using: "composite"
steps:
- name: Set base and head SHAs used for nx affected
id: setSHAs
shell: bash
env:
gh_token: ${{ github.token }}
main_branch_name: ${{ inputs.main-branch-name }}
error_on_no_successful_workflow: ${{ inputs.error-on-no-successful-workflow }}
last_successful_event: ${{ inputs.last-successful-event }}
working_directory: ${{ inputs.working-directory }}
working_id: ${{ inputs.workflow-id }}
run: node "$GITHUB_ACTION_PATH/dist/index.js" "$gh_token" "$main_branch_name" "$error_on_no_successful_workflow" "$last_successful_event" "$working_directory" "$working_id"
- name: Log base and head SHAs used for nx affected
shell: bash
run: |
echo "Base SHA"
echo ${{ steps.setSHAs.outputs.base }}
echo ""
echo "Head SHA"
echo ${{ steps.setSHAs.outputs.head }}
echo ""
- name: Optionally set the derived SHAs as NX_BASE and NX_HEAD environment variables for the current job
shell: bash
if: ${{ inputs.set-environment-variables-for-job == 'true' }}
run: |
echo "NX_BASE=${{ steps.setSHAs.outputs.base }}" >> $GITHUB_ENV
echo "NX_HEAD=${{ steps.setSHAs.outputs.head }}" >> $GITHUB_ENV
echo "NX_BASE and NX_HEAD environment variables have been set for the current Job"
branding:
icon: "terminal"
color: "blue"