Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/npm_and_yarn/eslint-9.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
amazreech authored May 10, 2024
2 parents 9fb56c6 + b54b045 commit 1d0a01e
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
runs-on: ubuntu-22.04
steps:
- name: validate
uses: actions/github-script@v6
uses: actions/github-script@v7
with:
script: |
// See https://gist.github.com/marcojahn/482410b728c31b221b70ea6d2c433f0c#file-conventional-commit-regex-md
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:

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

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

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

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@v3
56 changes: 33 additions & 23 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,41 @@
# When a pull request is opened/reopened or when the head branch of the pull request is updated.
on:
push:
branches:
- master
[pull_request]

name: Package

jobs:
check:
name: Package distribution file
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: master
- name: Node setup
uses: actions/setup-node@v4
with:
node-version: 20
- name: Package
run: |
npm ci
npm test
npm run package
- name: Commit
run: |
git config --global user.name "GitHub Actions"
git add dist/
git commit -m "chore: Update dist" || echo "No changes to commit"
git push origin HEAD:master
- name: Init a git repo
uses: actions/checkout@v4
- name: Checkout PR
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh pr checkout ${{ github.event.pull_request.number }}
- name: Node setup
uses: actions/setup-node@v4
with:
node-version: 20
- name: Package
run: |
npm ci
npm test
npm run package
- name: Commit to PR
if: github.actor == 'dependabot[bot]'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.name "GitHub Actions"
git add dist/
git commit -m "chore: Update dist" || echo "No changes to commit"
git push
- name: Check git diff
if: github.actor != 'dependabot[bot]'
run: |
git diff --exit-code dist/index.js
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ inputs:
command:
description: 'The command used by ECS to start the container image'
required: false
env-files:
description: 'S3 object arns to set env variables onto the container. You can specify multiple files with multi-line YAML strings.'
required: false
outputs:
task-definition:
description: 'The path to the rendered task definition file'
Expand Down
20 changes: 18 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ async function run() {
const containerName = core.getInput('container-name', { required: true });
const imageURI = core.getInput('image', { required: true });
const environmentVariables = core.getInput('environment-variables', { required: false });
const envFiles = core.getInput('env-files', { required: false });

const logConfigurationLogDriver = core.getInput("log-configuration-log-driver", { required: false });
const logConfigurationOptions = core.getInput("log-configuration-options", { required: false });
const dockerLabels = core.getInput('docker-labels', { required: false });
Expand Down Expand Up @@ -46,13 +48,27 @@ async function run() {
containerDef.command = command.split(' ')
}

if (environmentVariables) {
if (envFiles) {
containerDef.environmentFiles = [];
envFiles.split('\n').forEach(function (line) {
// Trim whitespace
const trimmedLine = line.trim();
// Skip if empty
if (trimmedLine.length === 0) { return; }
// Build object
const variable = {
value: trimmedLine,
type: "s3",
};
containerDef.environmentFiles.push(variable);
})
}

if (environmentVariables) {
// If environment array is missing, create it
if (!Array.isArray(containerDef.environment)) {
containerDef.environment = [];
}

// Get pairs by splitting on newlines
environmentVariables.split('\n').forEach(function (line) {
// Trim whitespace
Expand Down
20 changes: 18 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ async function run() {
const containerName = core.getInput('container-name', { required: true });
const imageURI = core.getInput('image', { required: true });
const environmentVariables = core.getInput('environment-variables', { required: false });
const envFiles = core.getInput('env-files', { required: false });

const logConfigurationLogDriver = core.getInput("log-configuration-log-driver", { required: false });
const logConfigurationOptions = core.getInput("log-configuration-options", { required: false });
const dockerLabels = core.getInput('docker-labels', { required: false });
Expand Down Expand Up @@ -40,13 +42,27 @@ async function run() {
containerDef.command = command.split(' ')
}

if (environmentVariables) {
if (envFiles) {
containerDef.environmentFiles = [];
envFiles.split('\n').forEach(function (line) {
// Trim whitespace
const trimmedLine = line.trim();
// Skip if empty
if (trimmedLine.length === 0) { return; }
// Build object
const variable = {
value: trimmedLine,
type: "s3",
};
containerDef.environmentFiles.push(variable);
})
}

if (environmentVariables) {
// If environment array is missing, create it
if (!Array.isArray(containerDef.environment)) {
containerDef.environment = [];
}

// Get pairs by splitting on newlines
environmentVariables.split('\n').forEach(function (line) {
// Trim whitespace
Expand Down
47 changes: 45 additions & 2 deletions index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ describe('Render task definition', () => {
.mockReturnValueOnce('task-definition.json') // task-definition
.mockReturnValueOnce('web') // container-name
.mockReturnValueOnce('nginx:latest') // image
.mockReturnValueOnce('FOO=bar\nHELLO=world'); // environment-variables
.mockReturnValueOnce('FOO=bar\nHELLO=world') // environment-variables
.mockReturnValueOnce('arn:aws:s3:::s3_bucket_name/envfile_object_name.env'); // env-files

process.env = Object.assign(process.env, { GITHUB_WORKSPACE: __dirname });
process.env = Object.assign(process.env, { RUNNER_TEMP: '/home/runner/work/_temp' });
Expand All @@ -53,6 +54,12 @@ describe('Render task definition', () => {
name: "DONT-TOUCH",
value: "me"
}
],
environmentFiles: [
{
value: "arn:aws:s3:::s3_bucket_name/envfile_object_name.env",
type: "s3"
}
]
},
{
Expand Down Expand Up @@ -92,6 +99,12 @@ describe('Render task definition', () => {
name: "HELLO",
value: "world"
}
],
environmentFiles: [
{
value: "arn:aws:s3:::s3_bucket_name/envfile_object_name.env",
type: "s3"
}
]
},
{
Expand All @@ -110,7 +123,9 @@ describe('Render task definition', () => {
.mockReturnValueOnce('/hello/task-definition.json') // task-definition
.mockReturnValueOnce('web') // container-name
.mockReturnValueOnce('nginx:latest') // image
.mockReturnValueOnce('EXAMPLE=here'); // environment-variables
.mockReturnValueOnce('EXAMPLE=here') // environment-variables
.mockReturnValueOnce('arn:aws:s3:::s3_bucket_name/envfile_object_name.env'); // env-files

jest.mock('/hello/task-definition.json', () => ({
family: 'task-def-family',
containerDefinitions: [
Expand All @@ -137,6 +152,12 @@ describe('Render task definition', () => {
{
name: "web",
image: "nginx:latest",
environmentFiles: [
{
value: "arn:aws:s3:::s3_bucket_name/envfile_object_name.env",
type: "s3"
}
],
environment: [
{
name: "EXAMPLE",
Expand All @@ -157,6 +178,7 @@ describe('Render task definition', () => {
.mockReturnValueOnce('web')
.mockReturnValueOnce('nginx:latest')
.mockReturnValueOnce('FOO=bar\nHELLO=world')
.mockReturnValueOnce('arn:aws:s3:::s3_bucket_name/envfile_object_name.env')
.mockReturnValueOnce('awslogs')
.mockReturnValueOnce(`awslogs-create-group=true\nawslogs-group=/ecs/web\nawslogs-region=us-east-1\nawslogs-stream-prefix=ecs`);

Expand Down Expand Up @@ -192,6 +214,12 @@ describe('Render task definition', () => {
value: "world"
}
],
environmentFiles: [
{
value: "arn:aws:s3:::s3_bucket_name/envfile_object_name.env",
type: "s3"
}
],
logConfiguration: {
logDriver: "awslogs",
options: {
Expand Down Expand Up @@ -231,6 +259,7 @@ describe('Render task definition', () => {
.mockReturnValueOnce('web')
.mockReturnValueOnce('nginx:latest')
.mockReturnValueOnce('EXAMPLE=here')
.mockReturnValueOnce('arn:aws:s3:::s3_bucket_name/envfile_object_name.env')
.mockReturnValueOnce('awslogs')
.mockReturnValueOnce('awslogs-create-group=true\nawslogs-group=/ecs/web\nawslogs-region=us-east-1\nawslogs-stream-prefix=ecs')
.mockReturnValueOnce('key1=value1\nkey2=value2');
Expand Down Expand Up @@ -270,6 +299,12 @@ describe('Render task definition', () => {
value: "here"
}
],
environmentFiles: [
{
value: "arn:aws:s3:::s3_bucket_name/envfile_object_name.env",
type: "s3"
}
],
logConfiguration: {
logDriver: "awslogs",
options: {
Expand Down Expand Up @@ -300,6 +335,7 @@ describe('Render task definition', () => {
.mockReturnValueOnce('web')
.mockReturnValueOnce('nginx:latest')
.mockReturnValueOnce('EXAMPLE=here')
.mockReturnValueOnce('arn:aws:s3:::s3_bucket_name/envfile_object_name.env')
.mockReturnValueOnce('awslogs')
.mockReturnValueOnce('awslogs-create-group=true\nawslogs-group=/ecs/web\nawslogs-region=us-east-1\nawslogs-stream-prefix=ecs')
.mockReturnValueOnce('key1=update_value1\nkey2\nkey3=value3');
Expand Down Expand Up @@ -383,6 +419,7 @@ describe('Render task definition', () => {
.mockReturnValueOnce('web')
.mockReturnValueOnce('nginx:latest')
.mockReturnValueOnce('EXAMPLE=here')
.mockReturnValueOnce('arn:aws:s3:::s3_bucket_name/envfile_object_name.env')
.mockReturnValueOnce('awslogs')
.mockReturnValueOnce('awslogs-create-group=true\nawslogs-group=/ecs/web\nawslogs-region=us-east-1\nawslogs-stream-prefix=ecs')
.mockReturnValueOnce('key1=value1\nkey2=value2')
Expand Down Expand Up @@ -423,6 +460,12 @@ describe('Render task definition', () => {
value: "here"
}
],
environmentFiles: [
{
value: "arn:aws:s3:::s3_bucket_name/envfile_object_name.env",
type: "s3"
}
],
logConfiguration: {
logDriver: "awslogs",
options: {
Expand Down

0 comments on commit 1d0a01e

Please sign in to comment.