Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3922b2b

Browse files
authored
Add a second action to delete deployment groups (e. g. after PR merge) (#31)
1 parent 49de04c commit 3922b2b

File tree

13 files changed

+119119
-55726
lines changed

13 files changed

+119119
-55726
lines changed

‎CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# create-aws-codedeploy-deployment Action Changelog
2+
3+
## Version v0.5.0
4+
5+
- Added a second action to remove deployment groups, e. g. after a PR has been closed or merged. In order to serve both actions from a single repository, the actions were moved to subdirectories. Refer to actions as `webfactory/create-aws-codedeploy-deployment/create-deployment@v0.5.0` and `webfactory/create-aws-codedeploy-deployment/delete-deployment-group@v0.5.0` respectively in your workflow's `uses:` clause.
6+
7+
## Previous versions
8+
9+
No dedicated changelog file has been written. Refer to https://github.com/webfactory/create-aws-codedeploy-deployment/releases for release information.

‎README.md

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ jobs:
4141
aws-access-key-id: ${{ secrets.ACCESS_KEY_ID }}
4242
aws-secret-access-key: ${{ secrets.SECRET_ACCESS_KEY }}
4343
aws-region: eu-central-1
44-
- uses: actions/checkout@v2
44+
- uses: actions/checkout@v4
4545
- id: deploy
46-
uses: webfactory/create-aws-codedeploy-deployment@v0.2.2
46+
uses: webfactory/create-aws-codedeploy-deployment/create-deployment@v0.5.0
4747
- uses: peter-evans/commit-comment@v2
4848
with:
4949
token: ${{ secrets.GITHUB_TOKEN }}
@@ -116,7 +116,7 @@ The only addition made will be that the `revision` parameter for `CreateDeployme
116116
2. Connect your CodeDeploy Application with your repository following [these instructions](https://docs.aws.amazon.com/codedeploy/latest/userguide/deployments-create-cli-github.html).
117117
3. Configure the [aws-actions/configure-aws-credentials](https://github.com/aws-actions/configure-aws-credentials) action in your workflow and provide the necessary IAM credentials as secrets. See the section below for the necessary IAM permissions.
118118
4. Add the `branch_config` section to your `appspec.yml` file to map branches to Deployment Groups and their configuration. In the above example, the `master` and `.*` sub-sections show the minimal configuration required.
119-
5. Add `uses: webfactory/create-aws-codedeploy-deployment@v0.1.0` as a step to your workflow file. If you want to use the action's outputs, you will also need to provide an `id` for the step.
119+
5. Add `uses: webfactory/create-aws-codedeploy-deployment/create-deployment@v0.5.0` as a step to your workflow file. If you want to use the action's outputs, you will also need to provide an `id` for the step.
120120

121121
### AWS IAM Permissions
122122

@@ -138,7 +138,8 @@ The IAM User that is used to run the action requires the following IAM permissio
138138
"codedeploy:GetDeploymentConfig",
139139
"codedeploy:GetDeploymentGroup",
140140
"codedeploy:UpdateDeploymentGroup",
141-
"codedeploy:CreateDeploymentGroup"
141+
"codedeploy:CreateDeploymentGroup",
142+
"codedeploy:DeleteDeploymentGroup"
142143
],
143144
"Resource": [
144145
"arn:aws:iam::{your_account_id}:role/{your_codedeploy_service_role}",
@@ -177,6 +178,34 @@ This workaround should catch a good share of possible out-of-order deployments.
177178

178179
You can use the expression `if: steps.<your-deployment-step>.outputs.deploymentGroupCreated==true` (or `...==false`) on subsequent workflow steps to run actions only if the deployment created a new deployment group (or updated an existing deployment, respectively).
179180

181+
## Cleaning Up
182+
183+
Sooner or later you might want to get rid of the CodeDeploy Deployment Groups created by this action. For example, when you create deployments for pull requests opened in a repo, you might want to delete those once the PR has been closed or merged.
184+
185+
To help you with this, a second action is included in this repo that can delete Deployment Groups, and uses the same rules to derive the group name as described above.
186+
187+
Here is an example workflow that runs for closed pull requests:
188+
189+
```yaml
190+
# .github/workflows/cleanup-deployment-groups.yml
191+
on:
192+
pull_request:
193+
types:
194+
- closed
195+
196+
jobs:
197+
deployment:
198+
runs-on: ubuntu-latest
199+
steps:
200+
- uses: aws-actions/configure-aws-credentials@v2
201+
with:
202+
aws-access-key-id: ${{ secrets.ACCESS_KEY_ID }}
203+
aws-secret-access-key: ${{ secrets.SECRET_ACCESS_KEY }}
204+
aws-region: eu-central-1
205+
- uses: actions/checkout@v4
206+
- uses: webfactory/create-aws-codedeploy-deployment/delete-deployment-group@v0.5.0
207+
```
208+
180209
## Hacking
181210

182211
As a note to my future self, in order to work on this repo:
@@ -197,4 +226,4 @@ If you're a developer looking for new challenges, we'd like to hear from you! Ot
197226
- <https://www.webfactory.de>
198227
- <https://twitter.com/webfactory>
199228

200-
Copyright 2020 - 2022 webfactory GmbH, Bonn. Code released under [the MIT license](LICENSE).
229+
Copyright 2020 - 2024 webfactory GmbH, Bonn. Code released under [the MIT license](LICENSE).

‎cli.js

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

‎action.yml renamed to ‎create-deployment/action.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: 'webfactory/create-aws-codedeploy-deployment'
1+
name: 'webfactory/create-aws-codedeploy-deployment/create-deployment'
22
description: 'An Action to deploy GitHub repos with AWS CodeDeploy'
33
inputs:
44
application:
@@ -17,8 +17,8 @@ outputs:
1717
deploymentGroupCreated:
1818
description: True, if a new deployment group was created; false if an already existing group was used.
1919
runs:
20-
using: 'node16'
21-
main: 'dist/index.js'
20+
using: 'node20'
21+
main: '../dist/create-deployment/index.js'
2222

2323
branding:
2424
icon: cast

‎delete-deployment-group/action.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: 'webfactory/create-aws-codedeploy-deployment/delete-deployment-group'
2+
description: 'Delete an AWS CodeDeploy deployment group, e. g. after a PR has been closed'
3+
inputs:
4+
application:
5+
description: 'AWS CodeDeploy application name; defaults to short repository name'
6+
config-name:
7+
description: 'Override name to look up branch_config; default is to use the current branch name.'
8+
default: ''
9+
outputs:
10+
deploymentGroupName:
11+
description: AWS CodeDeployment Deployment Group name used
12+
runs:
13+
using: 'node20'
14+
main: '../dist/delete-deployment-group/index.js'
15+
16+
branding:
17+
icon: cast
18+
color: orange

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /