Skip to content

Commit 1d0a01e

Browse files
authored
Merge branch 'master' into dependabot/npm_and_yarn/eslint-9.2.0
2 parents 9fb56c6 + b54b045 commit 1d0a01e

File tree

7 files changed

+122
-34
lines changed

7 files changed

+122
-34
lines changed

.github/workflows/check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
runs-on: ubuntu-22.04
2424
steps:
2525
- name: validate
26-
uses: actions/github-script@v6
26+
uses: actions/github-script@v7
2727
with:
2828
script: |
2929
// See https://gist.github.com/marcojahn/482410b728c31b221b70ea6d2c433f0c#file-conventional-commit-regex-md

.github/workflows/codeql-analysis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030

3131
steps:
3232
- name: Checkout repository
33-
uses: actions/checkout@v2
33+
uses: actions/checkout@v4
3434
with:
3535
# We must fetch at least the immediate parents so that if this is
3636
# a pull request then we can checkout the head.
@@ -43,7 +43,7 @@ jobs:
4343

4444
# Initializes the CodeQL tools for scanning.
4545
- name: Initialize CodeQL
46-
uses: github/codeql-action/init@v1
46+
uses: github/codeql-action/init@v3
4747
with:
4848
languages: ${{ matrix.language }}
4949
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -54,7 +54,7 @@ jobs:
5454
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
5555
# If this step fails, then you should remove it and run the build manually (see below)
5656
- name: Autobuild
57-
uses: github/codeql-action/autobuild@v1
57+
uses: github/codeql-action/autobuild@v3
5858

5959
# ℹ️ Command-line programs to run using the OS shell.
6060
# 📚 https://git.io/JvXDl
@@ -68,4 +68,4 @@ jobs:
6868
# make release
6969

7070
- name: Perform CodeQL Analysis
71-
uses: github/codeql-action/analyze@v1
71+
uses: github/codeql-action/analyze@v3

.github/workflows/package.yml

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,41 @@
1+
# When a pull request is opened/reopened or when the head branch of the pull request is updated.
12
on:
2-
push:
3-
branches:
4-
- master
3+
[pull_request]
54

65
name: Package
76

87
jobs:
98
check:
109
name: Package distribution file
11-
runs-on: ubuntu-22.04
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
1213
steps:
13-
- name: Checkout
14-
uses: actions/checkout@v4
15-
with:
16-
ref: master
17-
- name: Node setup
18-
uses: actions/setup-node@v4
19-
with:
20-
node-version: 20
21-
- name: Package
22-
run: |
23-
npm ci
24-
npm test
25-
npm run package
26-
- name: Commit
27-
run: |
28-
git config --global user.name "GitHub Actions"
29-
git add dist/
30-
git commit -m "chore: Update dist" || echo "No changes to commit"
31-
git push origin HEAD:master
14+
- name: Init a git repo
15+
uses: actions/checkout@v4
16+
- name: Checkout PR
17+
env:
18+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19+
run: gh pr checkout ${{ github.event.pull_request.number }}
20+
- name: Node setup
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: 20
24+
- name: Package
25+
run: |
26+
npm ci
27+
npm test
28+
npm run package
29+
- name: Commit to PR
30+
if: github.actor == 'dependabot[bot]'
31+
env:
32+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33+
run: |
34+
git config --global user.name "GitHub Actions"
35+
git add dist/
36+
git commit -m "chore: Update dist" || echo "No changes to commit"
37+
git push
38+
- name: Check git diff
39+
if: github.actor != 'dependabot[bot]'
40+
run: |
41+
git diff --exit-code dist/index.js

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ inputs:
2828
command:
2929
description: 'The command used by ECS to start the container image'
3030
required: false
31+
env-files:
32+
description: 'S3 object arns to set env variables onto the container. You can specify multiple files with multi-line YAML strings.'
33+
required: false
3134
outputs:
3235
task-definition:
3336
description: 'The path to the rendered task definition file'

dist/index.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ async function run() {
1616
const containerName = core.getInput('container-name', { required: true });
1717
const imageURI = core.getInput('image', { required: true });
1818
const environmentVariables = core.getInput('environment-variables', { required: false });
19+
const envFiles = core.getInput('env-files', { required: false });
20+
1921
const logConfigurationLogDriver = core.getInput("log-configuration-log-driver", { required: false });
2022
const logConfigurationOptions = core.getInput("log-configuration-options", { required: false });
2123
const dockerLabels = core.getInput('docker-labels', { required: false });
@@ -46,13 +48,27 @@ async function run() {
4648
containerDef.command = command.split(' ')
4749
}
4850

49-
if (environmentVariables) {
51+
if (envFiles) {
52+
containerDef.environmentFiles = [];
53+
envFiles.split('\n').forEach(function (line) {
54+
// Trim whitespace
55+
const trimmedLine = line.trim();
56+
// Skip if empty
57+
if (trimmedLine.length === 0) { return; }
58+
// Build object
59+
const variable = {
60+
value: trimmedLine,
61+
type: "s3",
62+
};
63+
containerDef.environmentFiles.push(variable);
64+
})
65+
}
5066

67+
if (environmentVariables) {
5168
// If environment array is missing, create it
5269
if (!Array.isArray(containerDef.environment)) {
5370
containerDef.environment = [];
5471
}
55-
5672
// Get pairs by splitting on newlines
5773
environmentVariables.split('\n').forEach(function (line) {
5874
// Trim whitespace

index.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ async function run() {
1010
const containerName = core.getInput('container-name', { required: true });
1111
const imageURI = core.getInput('image', { required: true });
1212
const environmentVariables = core.getInput('environment-variables', { required: false });
13+
const envFiles = core.getInput('env-files', { required: false });
14+
1315
const logConfigurationLogDriver = core.getInput("log-configuration-log-driver", { required: false });
1416
const logConfigurationOptions = core.getInput("log-configuration-options", { required: false });
1517
const dockerLabels = core.getInput('docker-labels', { required: false });
@@ -40,13 +42,27 @@ async function run() {
4042
containerDef.command = command.split(' ')
4143
}
4244

43-
if (environmentVariables) {
45+
if (envFiles) {
46+
containerDef.environmentFiles = [];
47+
envFiles.split('\n').forEach(function (line) {
48+
// Trim whitespace
49+
const trimmedLine = line.trim();
50+
// Skip if empty
51+
if (trimmedLine.length === 0) { return; }
52+
// Build object
53+
const variable = {
54+
value: trimmedLine,
55+
type: "s3",
56+
};
57+
containerDef.environmentFiles.push(variable);
58+
})
59+
}
4460

61+
if (environmentVariables) {
4562
// If environment array is missing, create it
4663
if (!Array.isArray(containerDef.environment)) {
4764
containerDef.environment = [];
4865
}
49-
5066
// Get pairs by splitting on newlines
5167
environmentVariables.split('\n').forEach(function (line) {
5268
// Trim whitespace

index.test.js

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ describe('Render task definition', () => {
2727
.mockReturnValueOnce('task-definition.json') // task-definition
2828
.mockReturnValueOnce('web') // container-name
2929
.mockReturnValueOnce('nginx:latest') // image
30-
.mockReturnValueOnce('FOO=bar\nHELLO=world'); // environment-variables
30+
.mockReturnValueOnce('FOO=bar\nHELLO=world') // environment-variables
31+
.mockReturnValueOnce('arn:aws:s3:::s3_bucket_name/envfile_object_name.env'); // env-files
3132

3233
process.env = Object.assign(process.env, { GITHUB_WORKSPACE: __dirname });
3334
process.env = Object.assign(process.env, { RUNNER_TEMP: '/home/runner/work/_temp' });
@@ -53,6 +54,12 @@ describe('Render task definition', () => {
5354
name: "DONT-TOUCH",
5455
value: "me"
5556
}
57+
],
58+
environmentFiles: [
59+
{
60+
value: "arn:aws:s3:::s3_bucket_name/envfile_object_name.env",
61+
type: "s3"
62+
}
5663
]
5764
},
5865
{
@@ -92,6 +99,12 @@ describe('Render task definition', () => {
9299
name: "HELLO",
93100
value: "world"
94101
}
102+
],
103+
environmentFiles: [
104+
{
105+
value: "arn:aws:s3:::s3_bucket_name/envfile_object_name.env",
106+
type: "s3"
107+
}
95108
]
96109
},
97110
{
@@ -110,7 +123,9 @@ describe('Render task definition', () => {
110123
.mockReturnValueOnce('/hello/task-definition.json') // task-definition
111124
.mockReturnValueOnce('web') // container-name
112125
.mockReturnValueOnce('nginx:latest') // image
113-
.mockReturnValueOnce('EXAMPLE=here'); // environment-variables
126+
.mockReturnValueOnce('EXAMPLE=here') // environment-variables
127+
.mockReturnValueOnce('arn:aws:s3:::s3_bucket_name/envfile_object_name.env'); // env-files
128+
114129
jest.mock('/hello/task-definition.json', () => ({
115130
family: 'task-def-family',
116131
containerDefinitions: [
@@ -137,6 +152,12 @@ describe('Render task definition', () => {
137152
{
138153
name: "web",
139154
image: "nginx:latest",
155+
environmentFiles: [
156+
{
157+
value: "arn:aws:s3:::s3_bucket_name/envfile_object_name.env",
158+
type: "s3"
159+
}
160+
],
140161
environment: [
141162
{
142163
name: "EXAMPLE",
@@ -157,6 +178,7 @@ describe('Render task definition', () => {
157178
.mockReturnValueOnce('web')
158179
.mockReturnValueOnce('nginx:latest')
159180
.mockReturnValueOnce('FOO=bar\nHELLO=world')
181+
.mockReturnValueOnce('arn:aws:s3:::s3_bucket_name/envfile_object_name.env')
160182
.mockReturnValueOnce('awslogs')
161183
.mockReturnValueOnce(`awslogs-create-group=true\nawslogs-group=/ecs/web\nawslogs-region=us-east-1\nawslogs-stream-prefix=ecs`);
162184

@@ -192,6 +214,12 @@ describe('Render task definition', () => {
192214
value: "world"
193215
}
194216
],
217+
environmentFiles: [
218+
{
219+
value: "arn:aws:s3:::s3_bucket_name/envfile_object_name.env",
220+
type: "s3"
221+
}
222+
],
195223
logConfiguration: {
196224
logDriver: "awslogs",
197225
options: {
@@ -231,6 +259,7 @@ describe('Render task definition', () => {
231259
.mockReturnValueOnce('web')
232260
.mockReturnValueOnce('nginx:latest')
233261
.mockReturnValueOnce('EXAMPLE=here')
262+
.mockReturnValueOnce('arn:aws:s3:::s3_bucket_name/envfile_object_name.env')
234263
.mockReturnValueOnce('awslogs')
235264
.mockReturnValueOnce('awslogs-create-group=true\nawslogs-group=/ecs/web\nawslogs-region=us-east-1\nawslogs-stream-prefix=ecs')
236265
.mockReturnValueOnce('key1=value1\nkey2=value2');
@@ -270,6 +299,12 @@ describe('Render task definition', () => {
270299
value: "here"
271300
}
272301
],
302+
environmentFiles: [
303+
{
304+
value: "arn:aws:s3:::s3_bucket_name/envfile_object_name.env",
305+
type: "s3"
306+
}
307+
],
273308
logConfiguration: {
274309
logDriver: "awslogs",
275310
options: {
@@ -300,6 +335,7 @@ describe('Render task definition', () => {
300335
.mockReturnValueOnce('web')
301336
.mockReturnValueOnce('nginx:latest')
302337
.mockReturnValueOnce('EXAMPLE=here')
338+
.mockReturnValueOnce('arn:aws:s3:::s3_bucket_name/envfile_object_name.env')
303339
.mockReturnValueOnce('awslogs')
304340
.mockReturnValueOnce('awslogs-create-group=true\nawslogs-group=/ecs/web\nawslogs-region=us-east-1\nawslogs-stream-prefix=ecs')
305341
.mockReturnValueOnce('key1=update_value1\nkey2\nkey3=value3');
@@ -383,6 +419,7 @@ describe('Render task definition', () => {
383419
.mockReturnValueOnce('web')
384420
.mockReturnValueOnce('nginx:latest')
385421
.mockReturnValueOnce('EXAMPLE=here')
422+
.mockReturnValueOnce('arn:aws:s3:::s3_bucket_name/envfile_object_name.env')
386423
.mockReturnValueOnce('awslogs')
387424
.mockReturnValueOnce('awslogs-create-group=true\nawslogs-group=/ecs/web\nawslogs-region=us-east-1\nawslogs-stream-prefix=ecs')
388425
.mockReturnValueOnce('key1=value1\nkey2=value2')
@@ -423,6 +460,12 @@ describe('Render task definition', () => {
423460
value: "here"
424461
}
425462
],
463+
environmentFiles: [
464+
{
465+
value: "arn:aws:s3:::s3_bucket_name/envfile_object_name.env",
466+
type: "s3"
467+
}
468+
],
426469
logConfiguration: {
427470
logDriver: "awslogs",
428471
options: {

0 commit comments

Comments
 (0)