Skip to content

Commit 3cceda0

Browse files
committed
build: who lotta cleanup and organization
1 parent 0b7e70e commit 3cceda0

18 files changed

+2058
-749
lines changed

.dependabot/config.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
version: 1
22
update_configs:
3-
- package_manager: "javascript"
4-
directory: "/"
5-
update_schedule: "monthly"
3+
- package_manager: 'javascript'
4+
directory: '/'
5+
update_schedule: 'monthly'
66
automerged_updates:
77
- match:
8-
dependency_type: "all"
9-
update_type: "semver:minor"
8+
dependency_type: 'all'
9+
update_type: 'semver:minor'

.eslintignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.DS_Store
2+
.github
3+
.vscode
4+
coverage/
5+
dist/
6+
node_modules/
7+
package-lock.json
8+
package.json
9+
typings.d.ts

.eslintrc.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
module.exports = {
2+
env: {
3+
es6: true,
4+
'jest/globals': true,
5+
node: true,
6+
},
7+
extends: [
8+
'eslint:recommended',
9+
// 'plugin:jest/all',
10+
'plugin:prettier/recommended',
11+
],
12+
globals: {
13+
Atomics: 'readonly',
14+
SharedArrayBuffer: 'readonly',
15+
},
16+
parserOptions: {
17+
ecmaVersion: 2018,
18+
},
19+
plugins: ['jest', 'prettier'],
20+
root: true,
21+
rules: {
22+
// 'import/order': [
23+
// 'error',
24+
// {
25+
// alphabetize: {
26+
// caseInsensitive: false,
27+
// order: 'asc',
28+
// },
29+
// groups: [
30+
// 'builtin',
31+
// 'external',
32+
// ['internal', 'parent', 'sibling', 'index'],
33+
// ],
34+
// 'newlines-between': 'always',
35+
// },
36+
// ],
37+
'max-params': ['error', 5],
38+
'no-console': ['error', { allow: ['warn', 'error'] }],
39+
'no-param-reassign': 'error',
40+
'no-var': 'error',
41+
'prefer-arrow-callback': ['error', { allowNamedFunctions: true }],
42+
'sort-keys': 'error',
43+
},
44+
};

.eslintrc.json

Lines changed: 0 additions & 18 deletions
This file was deleted.

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
*Issue #, if available:*
2-
3-
*Description of changes:*
1+
_Issue #, if available:_
42

3+
_Description of changes:_
54

65
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

.github/workflows/check.yml

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,52 @@
11
on:
2-
[pull_request]
2+
pull_request:
3+
push:
4+
branches:
5+
- f/**
6+
- p/**
7+
- renovate/**
38

4-
name: Check
9+
name: CI
510

611
jobs:
7-
check:
12+
lint:
813
name: Run Unit Tests
914
runs-on: ubuntu-latest
1015
steps:
11-
- name: Checkout
12-
uses: actions/checkout@v2
13-
- name: Run tests
14-
run: |
15-
npm ci
16-
npm test
16+
- name: Fetch all branches and tags
17+
run: git fetch --prune --unshallow
18+
19+
- name: NPM Cache
20+
uses: actions/cache@v1
21+
with:
22+
path: ~/.npm
23+
key: ${{ runner.os }}-npm-cache-${{ hashFiles('**/package-lock.json') }}
24+
25+
- name: NPM Install
26+
run: npm ci
27+
28+
# - name: Commitlint
29+
# if: ${{ github.event_name == 'pull_request' }}
30+
# run: npx commitlint --from origin/${{ github.base_ref }} --to origin/${{ github.head_ref }}
31+
32+
- name: Lint
33+
run: npm run lint
34+
35+
test:
36+
name: Test
37+
runs-on: ubuntu-latest
38+
steps:
39+
- name: Checkout
40+
uses: actions/checkout@v2
41+
42+
- name: NPM Cache
43+
uses: actions/cache@v1
44+
with:
45+
key: ${{ runner.os }}-npm-cache-${{ hashFiles('**/package-lock.json') }}
46+
path: ~/.npm
47+
48+
- name: NPM Install
49+
run: npm ci
50+
51+
- name: Test
52+
run: npm run test

.github/workflows/package.yml

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,19 @@ jobs:
1010
name: Package distribution file
1111
runs-on: ubuntu-latest
1212
steps:
13-
- name: Checkout
14-
uses: actions/checkout@v2
15-
with:
16-
ref: master
17-
- name: Package
18-
run: |
19-
npm ci
20-
npm test
21-
npm run package
22-
- name: Commit
23-
run: |
24-
git config --global user.name "GitHub Actions"
25-
git add dist/
26-
git commit -m "chore: Update dist" || echo "No changes to commit"
27-
git push origin HEAD:master
13+
- name: Checkout
14+
uses: actions/checkout@v2
15+
with:
16+
ref: master
17+
- name: Package
18+
run: |
19+
npm ci
20+
npm lint
21+
npm test
22+
npm run package
23+
- name: Commit
24+
run: |
25+
git config --global user.name "GitHub Actions"
26+
git add dist/
27+
git commit -m "chore: Update dist" || echo "No changes to commit"
28+
git push origin HEAD:master

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@ All notable changes to this project will be documented in this file. See [standa
44

55
## [1.0.0]
66

7+
Initial release of the action. Branched from
8+
https://github.com/aws-actions/amazon-ecs-deploy-task-definition.git
9+
and modified to support pushing to ecs scheduled tasks instead of ECS
10+
services.
711

812
### Features
913

10-
### Bug Fixes
14+
- Adds in support for ESC scheduled tasks.
15+
- Adds in tests to validat logic.
16+
- Removes service deployment code.

LICENSE

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
MIT License
22

3-
Copyright 2019 Amazon.com, Inc. or its affiliates.
4-
53
Permission is hereby granted, free of charge, to any person obtaining a copy
64
of this software and associated documentation files (the "Software"), to deal
75
in the Software without restriction, including without limitation the rights

README.md

Lines changed: 11 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,32 @@
1-
## Amazon ECS "Deploy Task Definition" Action for GitHub Actions
1+
## ECS "Deploy Task Definition to Scheduled Tasks" Action for GitHub Actions
22

3-
Registers an Amazon ECS task definition and deploys it to an ECS service.
3+
Registers an Amazon ECS task definition and deploys it to scheduled tasks in a given ECS cluster
44

55
**Table of Contents**
66

77
<!-- toc -->
88

9+
- [Acknowledgements](#acknowledgements)
910
- [Usage](#usage)
1011
- [Credentials and Region](#credentials-and-region)
1112
- [Permissions](#permissions)
12-
- [AWS CodeDeploy Support](#aws-codedeploy-support)
1313
- [Troubleshooting](#troubleshooting)
1414
- [License Summary](#license-summary)
15-
- [Security Disclosures](#security-disclosures)
1615

1716
<!-- tocstop -->
1817

18+
## Acknowledgements
19+
This project is a fork of the [amazon-ecs-deploy-task-definition](https://github.com/aws-actions/amazon-ecs-deploy-task-definition) that has been modified and re-tooled to work with ECS scheduled tasks.
20+
1921
## Usage
22+
The action assumes you have already setup 1 or more tasks to run as a scheduled task in the ECS environment. This action will update _all_ of the tasks who cluster and task ARN (without version) match existing scheduled actions. To use this action simply add the following step to your deploy process:
2023

2124
```yaml
22-
- name: Deploy to Amazon ECS
23-
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
25+
- name: Deploy to Amazon ECS Scheduled Tasks
26+
uses: airfordable/ecs-deploy-task-definition-to-scheduled-task@v1.0.0
2427
with:
25-
task-definition: task-definition.json
26-
service: my-service
2728
cluster: my-cluster
28-
wait-for-service-stability: true
29+
task-definition: task-definition.json
2930
```
3031
3132
The action can be passed a `task-definition` generated dynamically via [the `aws-actions/amazon-ecs-render-task-definition` action](https://github.com/aws-actions/amazon-ecs-render-task-definition).
@@ -37,7 +38,7 @@ See [action.yml](action.yml) for the full documentation for this action's inputs
3738
This action relies on the [default behavior of the AWS SDK for Javascript](https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-credentials-node.html) to determine AWS credentials and region.
3839
Use [the `aws-actions/configure-aws-credentials` action](https://github.com/aws-actions/configure-aws-credentials) to configure the GitHub Actions environment with environment variables containing AWS credentials and your desired region.
3940

40-
We recommend following [Amazon IAM best practices](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html) for the AWS credentials used in GitHub Actions workflows, including:
41+
Amazon recommends following [Amazon IAM best practices](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html) for the AWS credentials used in GitHub Actions workflows, including:
4142
* Do not store credentials in your repository's code. You may use [GitHub Actions secrets](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets) to store credentials and redact credentials from GitHub Actions workflow logs.
4243
* [Create an individual IAM user](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#create-iam-users) with an access key for use in GitHub Actions workflows, preferably one per repository. Do not use the AWS account root user access key.
4344
* [Grant least privilege](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#grant-least-privilege) to the credentials used in GitHub Actions workflows. Grant only the permissions required to perform the actions in your GitHub Actions workflows. See the Permissions section below for the permissions required by this action.
@@ -70,96 +71,17 @@ This action requires the following minimum set of permissions:
7071
"arn:aws:iam::<aws_account_id>:role/<task_definition_task_role_name>",
7172
"arn:aws:iam::<aws_account_id>:role/<task_definition_task_execution_role_name>"
7273
]
73-
},
74-
{
75-
"Sid":"DeployService",
76-
"Effect":"Allow",
77-
"Action":[
78-
"ecs:UpdateService",
79-
"ecs:DescribeServices"
80-
],
81-
"Resource":[
82-
"arn:aws:ecs:<region>:<aws_account_id>:service/<cluster_name>/<service_name>"
83-
]
8474
}
8575
]
8676
}
8777
```
8878

8979
Note: the policy above assumes the account has opted in to the ECS long ARN format.
9080

91-
## AWS CodeDeploy Support
92-
93-
For ECS services that uses the `CODE_DEPLOY` deployment controller, additional configuration is needed for this action:
94-
95-
```yaml
96-
- name: Deploy to Amazon ECS
97-
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
98-
with:
99-
task-definition: task-definition.json
100-
service: my-service
101-
cluster: my-cluster
102-
wait-for-service-stability: true
103-
codedeploy-appspec: appspec.json
104-
codedeploy-application: my-codedeploy-application
105-
codedeploy-deployment-group: my-codedeploy-deployment-group
106-
```
107-
108-
The minimal permissions require access to CodeDeploy:
109-
110-
```json
111-
{
112-
"Version":"2012-10-17",
113-
"Statement":[
114-
{
115-
"Sid":"RegisterTaskDefinition",
116-
"Effect":"Allow",
117-
"Action":[
118-
"ecs:RegisterTaskDefinition"
119-
],
120-
"Resource":"*"
121-
},
122-
{
123-
"Sid":"PassRolesInTaskDefinition",
124-
"Effect":"Allow",
125-
"Action":[
126-
"iam:PassRole"
127-
],
128-
"Resource":[
129-
"arn:aws:iam::<aws_account_id>:role/<task_definition_task_role_name>",
130-
"arn:aws:iam::<aws_account_id>:role/<task_definition_task_execution_role_name>"
131-
]
132-
},
133-
{
134-
"Sid":"DeployService",
135-
"Effect":"Allow",
136-
"Action":[
137-
"ecs:DescribeServices",
138-
"codedeploy:GetDeploymentGroup",
139-
"codedeploy:CreateDeployment",
140-
"codedeploy:GetDeployment",
141-
"codedeploy:GetDeploymentConfig",
142-
"codedeploy:RegisterApplicationRevision"
143-
],
144-
"Resource":[
145-
"arn:aws:ecs:<region>:<aws_account_id>:service/<cluster_name>/<service_name>",
146-
"arn:aws:codedeploy:<region>:<aws_account_id>:deploymentgroup:<application_name>/<deployment_group_name>",
147-
"arn:aws:codedeploy:<region>:<aws_account_id>:deploymentconfig:*",
148-
"arn:aws:codedeploy:<region>:<aws_account_id>:application:<application_name>"
149-
]
150-
}
151-
]
152-
}
153-
```
154-
15581
## Troubleshooting
15682

15783
This action emits debug logs to help troubleshoot deployment failures. To see the debug logs, create a secret named `ACTIONS_STEP_DEBUG` with value `true` in your repository.
15884

15985
## License Summary
16086

16187
This code is made available under the MIT license.
162-
163-
## Security Disclosures
164-
165-
If you would like to report a potential security issue in this project, please do not create a GitHub issue. Instead, please follow the instructions [here](https://aws.amazon.com/security/vulnerability-reporting/) or [email AWS security directly](mailto:[email protected]).

0 commit comments

Comments
 (0)