Skip to content

Commit ed68249

Browse files
committed
add codeowners file; update token permission to read only for workflow
and validate GO_VERSION is of the correct format and length
1 parent 95e33aa commit ed68249

File tree

5 files changed

+68
-10
lines changed

5 files changed

+68
-10
lines changed

.github/CODEOWNERS

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners
2+
3+
# These owners will be the default owners for everything in
4+
# the repo. Unless a later match takes precedence, these accounts
5+
# will be requested for review when someone opens a pull request.
6+
* @aws/aws-ecs-agent

.github/workflows/gitsecrets.yml

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: GitSecretsScan
22

33
on: [push, pull_request]
44

5+
permissions: read-all
56
jobs:
67
git-secret-check:
78
name: Git Secrets Scan

.github/workflows/linux.yml

+13-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: Linux
22

33
on: [pull_request]
44

5+
permissions: read-all
56
jobs:
67
unit-tests:
78
name: Linux unit tests
@@ -11,12 +12,22 @@ jobs:
1112
with:
1213
path: src/github.com/aws/amazon-ecs-agent
1314
- name: get GO_VERSION
15+
id: get-go-version
1416
run: |
1517
cd $GITHUB_WORKSPACE/src/github.com/aws/amazon-ecs-agent
16-
echo "GO_VERSION=$(cat GO_VERSION)" >> $GITHUB_ENV
18+
set -eou pipefail
19+
go_version=$(cat -e GO_VERSION)
20+
go_version=${go_version%?}
21+
go_version_length=${#go_version}
22+
go_version_re="^([0-9]+\.){1,2}([0-9]+)$"
23+
if ! [[ $go_version_length -le 10 && $go_version =~ $go_version_re ]] ; then
24+
echo "invalid GO version"
25+
exit 1
26+
fi
27+
echo "::set-output name=GO_VERSION::$go_version"
1728
- uses: actions/setup-go@v2
1829
with:
19-
go-version: ${{ env.GO_VERSION }}
30+
go-version: ${{ steps.get-go-version.outputs.GO_VERSION }}
2031
- uses: actions/checkout@v2
2132
with:
2233
submodules: true

.github/workflows/static.yml

+37-6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: Static Checks
22

33
on: [push, pull_request]
44

5+
permissions: read-all
56
jobs:
67
static-check:
78
name: Static Analysis
@@ -11,12 +12,22 @@ jobs:
1112
with:
1213
path: src/github.com/aws/amazon-ecs-agent
1314
- name: get GO_VERSION
15+
id: get-go-version
1416
run: |
1517
cd $GITHUB_WORKSPACE/src/github.com/aws/amazon-ecs-agent
16-
echo "GO_VERSION=$(cat GO_VERSION)" >> $GITHUB_ENV
18+
set -eou pipefail
19+
go_version=$(cat -e GO_VERSION)
20+
go_version=${go_version%?}
21+
go_version_length=${#go_version}
22+
go_version_re="^([0-9]+\.){1,2}([0-9]+)$"
23+
if ! [[ $go_version_length -le 10 && $go_version =~ $go_version_re ]] ; then
24+
echo "invalid GO version"
25+
exit 1
26+
fi
27+
echo "::set-output name=GO_VERSION::$go_version"
1728
- uses: actions/setup-go@v2
1829
with:
19-
go-version: ${{ env.GO_VERSION }}
30+
go-version: ${{ steps.get-go-version.outputs.GO_VERSION }}
2031
- uses: actions/checkout@v2
2132
with:
2233
path: src/github.com/aws/amazon-ecs-agent
@@ -37,12 +48,22 @@ jobs:
3748
with:
3849
path: src/github.com/aws/amazon-ecs-agent
3950
- name: get GO_VERSION
51+
id: get-go-version
4052
run: |
4153
cd $GITHUB_WORKSPACE/src/github.com/aws/amazon-ecs-agent
42-
echo "GO_VERSION=$(cat GO_VERSION)" >> $GITHUB_ENV
54+
set -eou pipefail
55+
go_version=$(cat -e GO_VERSION)
56+
go_version=${go_version%?}
57+
go_version_length=${#go_version}
58+
go_version_re="^([0-9]+\.){1,2}([0-9]+)$"
59+
if ! [[ $go_version_length -le 10 && $go_version =~ $go_version_re ]] ; then
60+
echo "invalid GO version"
61+
exit 1
62+
fi
63+
echo "::set-output name=GO_VERSION::$go_version"
4364
- uses: actions/setup-go@v2
4465
with:
45-
go-version: ${{ env.GO_VERSION }}
66+
go-version: ${{ steps.get-go-version.outputs.GO_VERSION }}
4667
- uses: actions/checkout@v2
4768
with:
4869
path: src/github.com/aws/amazon-ecs-agent
@@ -63,12 +84,22 @@ jobs:
6384
with:
6485
path: src/github.com/aws/amazon-ecs-agent
6586
- name: get GO_VERSION
87+
id: get-go-version
6688
run: |
6789
cd $GITHUB_WORKSPACE/src/github.com/aws/amazon-ecs-agent
68-
echo "GO_VERSION=$(cat GO_VERSION)" >> $GITHUB_ENV
90+
set -eou pipefail
91+
go_version=$(cat -e GO_VERSION)
92+
go_version=${go_version%?}
93+
go_version_length=${#go_version}
94+
go_version_re="^([0-9]+\.){1,2}([0-9]+)$"
95+
if ! [[ $go_version_length -le 10 && $go_version =~ $go_version_re ]] ; then
96+
echo "invalid GO version"
97+
exit 1
98+
fi
99+
echo "::set-output name=GO_VERSION::$go_version"
69100
- uses: actions/setup-go@v2
70101
with:
71-
go-version: ${{ env.GO_VERSION }}
102+
go-version: ${{ steps.get-go-version.outputs.GO_VERSION }}
72103
- uses: actions/checkout@v2
73104
with:
74105
submodules: true

.github/workflows/windows.yml

+11-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: Windows
22

33
on: [pull_request]
44

5+
permissions: read-all
56
jobs:
67
windows-unit-tests:
78
name: Windows unit tests
@@ -11,13 +12,21 @@ jobs:
1112
with:
1213
path: src/github.com/aws/amazon-ecs-agent
1314
- name: get GO_VERSION
15+
id: get-go-version
1416
run: |
1517
cd "$Env:GITHUB_WORKSPACE"
1618
cd "src/github.com/aws/amazon-ecs-agent"
17-
echo "GO_VERSION_WINDOWS=$(type GO_VERSION_WINDOWS)" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
19+
$ErrorActionPreference = "Stop"
20+
$go_version_win = $(type GO_VERSION_WINDOWS)
21+
$go_version_re = "^\d+\.{1,2}\d+$"
22+
if (-Not ($go_version_win.Length -le 10 -or $go_version_win -match $go_version_re) ) {
23+
echo "invalid GO version"
24+
exit 1
25+
}
26+
Write-Output "::set-output name=GO_VERSION_WINDOWS::$go_version_win"
1827
- uses: actions/setup-go@v2
1928
with:
20-
go-version: ${{ env.GO_VERSION_WINDOWS }}
29+
go-version: ${{ steps.get-go-version.outputs.GO_VERSION_WINDOWS }}
2130
- uses: actions/checkout@v2
2231
with:
2332
submodules: true

0 commit comments

Comments
 (0)