github_actions/vars.rs
1//! [Default environment variables](https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables)
2
3macro_rules! decl_const {
4 (
5 $(#[$doc:meta])*
6 $name:ident
7 ) => {
8 $(#[$doc])*
9 pub const $name: &str = stringify!($name);
10 };
11}
12
13decl_const!(
14 /// Always set to `true`.
15 CI
16);
17
18decl_const!(
19 /// The name of the action currently running, or the [id](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsid) of a step. For example, for an action, `__repo-owner_name-of-action-repo`.
20 ///
21 /// GitHub removes special characters, and uses the name `__run` when the current step runs a script without an `id`. If you use the same script or action more than once in the same job, the name will include a suffix that consists of the sequence number preceded by an underscore. For example, the first script you run will have the name `__run`, and the second script will be named `__run_2`. Similarly, the second invocation of `actions/checkout` will be `actionscheckout2`.
22 GITHUB_ACTION
23);
24
25decl_const!(
26 /// The path where an action is located. This property is only supported in composite actions. You can use this path to change directories to where the action is located and access other files in that same repository. For example, `/home/runner/work/_actions/repo-owner/name-of-action-repo/v1`.
27 GITHUB_ACTION_PATH
28);
29
30decl_const!(
31 /// For a step executing an action, this is the owner and repository name of the action. For example, `actions/checkout`.
32 GITHUB_ACTION_REPOSITORY
33);
34
35decl_const!(
36 /// Always set to `true` when GitHub Actions is running the workflow. You can use this variable to differentiate when tests are being run locally or by GitHub Actions.
37 GITHUB_ACTIONS
38);
39
40decl_const!(
41 /// The name of the person or app that initiated the workflow. For example, `octocat`.
42 GITHUB_ACTOR
43);
44
45decl_const!(
46 /// The account ID of the person or app that triggered the initial workflow run. For example, `1234567`. Note that this is different from the actor username.
47 GITHUB_ACTOR_ID
48);
49
50decl_const!(
51 /// Returns the API URL. For example: `https://api.github.com`.
52 GITHUB_API_URL
53);
54
55decl_const!(
56 /// The name of the base ref or target branch of the pull request in a workflow run. This is only set when the event that triggers a workflow run is either `pull_request` or `pull_request_target`. For example, `main`.
57 GITHUB_BASE_REF
58);
59
60decl_const!(
61 /// The path on the runner to the file that sets variables from workflow commands. This file is unique to the current step and changes for each step in a job. For example, `/home/runner/work/_temp/_runner_file_commands/set_env_87406d6e-4979-4d42-98e1-3dab1f48b13a`. For more information, see "[Workflow commands for GitHub Actions](https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable)."
62 GITHUB_ENV
63);
64
65decl_const!(
66 /// The name of the event that triggered the workflow. For example, `workflow_dispatch`.
67 GITHUB_EVENT_NAME
68);
69
70decl_const!(
71 /// The path to the file on the runner that contains the full event webhook payload. For example, `/github/workflow/event.json`.
72 GITHUB_EVENT_PATH
73);
74
75decl_const!(
76 /// Returns the GraphQL API URL. For example: `https://api.github.com/graphql`.
77 GITHUB_GRAPHQL_URL
78);
79
80decl_const!(
81 /// The head ref or source branch of the pull request in a workflow run. This property is only set when the event that triggers a workflow run is either `pull_request` or `pull_request_target`. For example, `feature-branch-1`.
82 GITHUB_HEAD_REF
83);
84
85decl_const!(
86 /// The [job_id](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_id) of the current job. For example, `greeting_job`.
87 GITHUB_JOB
88);
89
90decl_const!(
91 /// The path on the runner to the file that sets the current step's outputs from workflow commands. This file is unique to the current step and changes for each step in a job. For example, `/home/runner/work/_temp/_runner_file_commands/set_output_a50ef383-b063-46d9-9157-57953fc9f3f0`. For more information, see "[Workflow commands for GitHub Actions](https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-output-parameter)."
92 GITHUB_OUTPUT
93);
94
95decl_const!(
96 /// The path on the runner to the file that sets system `PATH` variables from workflow commands. This file is unique to the current step and changes for each step in a job. For example, `/home/runner/work/_temp/_runner_file_commands/add_path_899b9445-ad4a-400c-aa89-249f18632cf5`. For more information, see "[Workflow commands for GitHub Actions](https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#adding-a-system-path)."
97 GITHUB_PATH
98);
99
100decl_const!(
101 /// The fully-formed ref of the branch or tag that triggered the workflow run. For workflows triggered by `push`, this is the branch or tag ref that was pushed. For workflows triggered by `pull_request`, this is the pull request merge branch. For workflows triggered by `release`, this is the release tag created. For other triggers, this is the branch or tag ref that triggered the workflow run. This is only set if a branch or tag is available for the event type. The ref given is fully-formed, meaning that for branches the format is `refs/heads/<branch_name>`, for pull requests it is `refs/pull/<pr_number>/merge`, and for tags it is `refs/tags/<tag_name>`. For example, `refs/heads/feature-branch-1`.
102 GITHUB_REF
103);
104
105decl_const!(
106 /// The short ref name of the branch or tag that triggered the workflow run. This value matches the branch or tag name shown on GitHub. For example, `feature-branch-1.`
107 ///
108 /// For pull requests, the format is `<pr_number>/merge`.
109 GITHUB_REF_NAME
110);
111
112decl_const!(
113 /// `true` if branch protections or [rulesets](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-rulesets/managing-rulesets-for-a-repository) are configured for the ref that triggered the workflow run.
114 GITHUB_REF_PROTECTED
115);
116
117decl_const!(
118 /// The type of ref that triggered the workflow run. Valid values are `branch` or `tag`.
119 GITHUB_REF_TYPE
120);
121
122decl_const!(
123 /// The owner and repository name. For example, `octocat/Hello-World`.
124 GITHUB_REPOSITORY
125);
126
127decl_const!(
128 /// The ID of the repository. For example, `123456789`. Note that this is different from the repository name.
129 GITHUB_REPOSITORY_ID
130);
131
132decl_const!(
133 /// The repository owner's name. For example, `octocat`.
134 GITHUB_REPOSITORY_OWNER
135);
136
137decl_const!(
138 /// The repository owner's account ID. For example, `1234567`. Note that this is different from the owner's name.
139 GITHUB_REPOSITORY_OWNER_ID
140);
141
142decl_const!(
143 /// The number of days that workflow run logs and artifacts are kept. For example, `90`.
144 GITHUB_RETENTION_DAYS
145);
146
147decl_const!(
148 /// A unique number for each attempt of a particular workflow run in a repository. This number begins at 1 for the workflow run's first attempt, and increments with each re-run. For example, `3`.
149 GITHUB_RUN_ATTEMPT
150);
151
152decl_const!(
153 /// A unique number for each workflow run within a repository. This number does not change if you re-run the workflow run. For example, `1658821493`.
154 GITHUB_RUN_ID
155);
156
157decl_const!(
158 /// A unique number for each run of a particular workflow in a repository. This number begins at 1 for the workflow's first run, and increments with each new run. This number does not change if you re-run the workflow run. For example, `3`.
159 GITHUB_RUN_NUMBER
160);
161
162decl_const!(
163 /// The URL of the GitHub server. For example: `https://github.com`.
164 GITHUB_SERVER_URL
165);
166
167decl_const!(
168 /// The commit SHA that triggered the workflow. The value of this commit SHA depends on the event that triggered the workflow. For more information, see "[Events that trigger workflows](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows)." For example, `ffac537e6cbbf934b08745a378932722df287a53`.
169 GITHUB_SHA
170);
171
172decl_const!(
173 /// The path on the runner to the file that may be used to [share state with pre: and post: actions](https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#sending-values-to-the-pre-and-post-actions).
174 GITHUB_STATE
175);
176
177decl_const!(
178 /// The path on the runner to the file that contains job summaries from workflow commands. This file is unique to the current step and changes for each step in a job. For example, `/home/runner/_layout/_work/_temp/_runner_file_commands/step_summary_1cb22d7f-5663-41a8-9ffc-13472605c76c`. For more information, see "[Workflow commands for GitHub Actions](https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary)."
179 GITHUB_STEP_SUMMARY
180);
181
182decl_const!(
183 /// The username of the user that initiated the workflow run. If the workflow run is a re-run, this value may differ from `github.actor`. Any workflow re-runs will use the privileges of `github.actor`, even if the actor initiating the re-run (`github.triggering_actor`) has different privileges.
184 GITHUB_TRIGGERING_ACTOR
185);
186
187decl_const!(
188 /// The name of the workflow. For example, `My test workflow`. If the workflow file doesn't specify a `name`, the value of this variable is the full path of the workflow file in the repository.
189 GITHUB_WORKFLOW
190);
191
192decl_const!(
193 /// The ref path to the workflow. For example, `octocat/hello-world/.github/workflows/my-workflow.yml@refs/heads/my_branch`.
194 GITHUB_WORKFLOW_REF
195);
196
197decl_const!(
198 /// The commit SHA for the workflow file.
199 GITHUB_WORKFLOW_SHA
200);
201
202decl_const!(
203 /// The default working directory on the runner for steps, and the default location of your repository when using the [checkout](https://github.com/actions/checkout) action. For example, `/home/runner/work/my-repo-name/my-repo-name`.
204 GITHUB_WORKSPACE
205);
206
207decl_const!(
208 /// The architecture of the runner executing the job. Possible values are `X86`, `X64`, `ARM`, or `ARM64`.
209 RUNNER_ARCH
210);
211
212decl_const!(
213 /// This is set only if [debug logging](https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/enabling-debug-logging) is enabled, and always has the value of `1`. It can be useful as an indicator to enable additional debugging or verbose logging in your own job steps.
214 RUNNER_DEBUG
215);
216
217decl_const!(
218 /// The environment of the runner executing the job. Possible values are: `github-hosted` for GitHub-hosted runners provided by GitHub, and `self-hosted` for self-hosted runners configured by the repository owner.
219 RUNNER_ENVIRONMENT
220);
221
222decl_const!(
223 /// The name of the runner executing the job. This name may not be unique in a workflow run as runners at the repository and organization levels could use the same name. For example, `Hosted Agent`
224 RUNNER_NAME
225);
226
227decl_const!(
228 /// The operating system of the runner executing the job. Possible values are `Linux`, `Windows`, or `macOS`. For example, `Windows`
229 RUNNER_OS
230);
231
232decl_const!(
233 /// The path to a temporary directory on the runner. This directory is emptied at the beginning and end of each job. Note that files will not be removed if the runner's user account does not have permission to delete them. For example, `D:\a\_temp`
234 RUNNER_TEMP
235);
236
237decl_const!(
238 /// The path to the directory containing preinstalled tools for GitHub-hosted runners. For more information, see "[Using GitHub-hosted runners](https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-software)". For example, `C:\hostedtoolcache\windows`
239 RUNNER_TOOL_CACHE
240);