Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f19f0bb

Browse files
committed
Actions now support global env vars
Thanks again to Nick for spotting this.
1 parent c4ab083 commit f19f0bb

File tree

1 file changed

+18
-29
lines changed

1 file changed

+18
-29
lines changed

README.md

Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -46,28 +46,15 @@ module mode by default. To turn it on explicitly, set `GO111MODULE=on`.
4646

4747
#### How do I set environent variables?
4848

49-
They can only be set for each step, as far as the documentation covers:
49+
They can be set up via `env` for an [entire
50+
workflow](https://help.github.com/en/articles/workflow-syntax-for-github-actions#env),
51+
a job, or for each step:
5052

5153
```
52-
- name: Download Go dependencies with a custom proxy
53-
env:
54-
GOPROXY: "https://proxy.company.com"
55-
run: go mod download
56-
```
57-
58-
On Go 1.13 and later, this can be simplified:
59-
60-
```
61-
- name: Set Go env vars
62-
run: go env -w GOPROXY="https://proxy.company.com"
63-
```
64-
65-
There also appears to be an undocumented way to set global environment
66-
variables, as found by [Nick Craig-Wood](https://twitter.com/njcw):
67-
68-
```
69-
- name: Set global env vars
70-
run: echo '::set-env name=NAME::VALUE'
54+
env:
55+
GOPROXY: "https://proxy.company.com"
56+
jobs:
57+
[...]
7158
```
7259

7360
#### How do I set up caching between builds?
@@ -147,17 +134,19 @@ Use `sudo apt`, making sure to only run the step on Linux:
147134

148135
#### How do I set up a GOPATH build?
149136

150-
We can set up a GOPATH with global environment variables, as explained earlier:
137+
Declare GOPATH and clone inside it:
151138

152139
```
153-
- name: Checkout code
154-
uses: actions/checkout@v1
155-
with:
156-
path: ./src/github.com/${{ github.repository }}
157-
- name: Set GOPATH
158-
run: |
159-
echo '::set-env name=GOPATH::${{ runner.workspace }}'
160-
echo '::add-path::${{ runner.workspace }}/bin'
140+
jobs:
141+
test-gopath:
142+
env:
143+
GOPATH: ${{ runner.workspace }}
144+
GO111MODULE: off
145+
steps:
146+
- name: Checkout code
147+
uses: actions/checkout@v1
148+
with:
149+
path: ./src/github.com/${{ github.repository }}
161150
```
162151

163152
## Quick links

0 commit comments

Comments
 (0)