Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix release deletion and add new inputs #5

Merged
merged 4 commits into from
Nov 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/clean-up-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@ name: Delete Release Candidates

on:
pull_request:
types: [ closed ]
types: [ closed, labeled ]


jobs:
delete-release-candidates:
name: Delete Release Candidates
if: github.event.action == 'closed' || github.event.label.name == 'delete-releases'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Delete release candidates
uses: ./
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
release-identifier: '-pr${{ github.event.number }}-rc'
23 changes: 14 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@ This action is used to automate the removal of release candidates that are typic

## Inputs

| Input | Description | Required | Default |
|-----------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------|----------------|
| release-identifier | A string that will be used to identify the releases to be deleted (eg. "pr1234"). | true | |
| ecr-name | The name of an ECR where to look for container images tagged with the releases we are deleting. The name is not the full URL, it is just the last bit of the URL. | false | |
| s3-bucket | The name of a S3 bucket where to look for artefacts tagged with the releases we are deleting. | false | |
| s3-object-key-prefix | The S3 object key prefix used to look for artefacts tagged with the releases we are deleting. | false | |
| aws-access-key-id | The AWS access key ID providing access to delete artefacts from either or both ECR and S3 Bucket. | false | |
| aws-secret-access-key | The runtimes where to deploy the release. | false | |
| aws-region | The AWS region. | false | 'eu-central-1' |
| Input | Description | Required | Default |
|-----------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------|----------------|
| release-identifier | A string that will be used to identify the releases to be deleted (eg. "pr1234"). | true | |
| keep-latest-count | The number of matches releases to keep, ordered from latest to oldest. | true | '0' |
| ecr-name | The name of an ECR where to look for container images tagged with the releases we are deleting. The name is not the full URL, it is just the last bit of the URL. | false | |
| s3-bucket | The name of a S3 bucket where to look for artefacts tagged with the releases we are deleting. | false | |
| s3-object-key-prefix | The S3 object key prefix used to look for artefacts tagged with the releases we are deleting. | false | |
| github-token | The github token used to delete the releases and tags. | true | |
| aws-access-key-id | The AWS access key ID providing access to delete artefacts from either or both ECR and S3 Bucket. | false | |
| aws-secret-access-key | The runtimes where to deploy the release. | false | |
| aws-region | The AWS region. | false | 'eu-central-1' |

## Outputs

Expand Down Expand Up @@ -52,6 +54,7 @@ jobs:
- uses: GRESB/action-delete-release-candidates
with:
release-identifier: '-pr${{ github.event.number }}-rc'
github-token: ${{ secrets.GITHUB_TOKEN }}
```

## Remove GitHub Releases and S3 Artefacts
Expand All @@ -78,6 +81,7 @@ jobs:
release-identifier: '-pr${{ github.event.number }}-rc'
s3-bucket: 'my-bucket'
s3-object-key-prefix: 'my-app/packages'
github-token: ${{ secrets.GITHUB_TOKEN }}
aws-access-key-id: ${{ secrets.aws-access-key-id }}
aws-secret-access-key: ${{ secrets.aws-secret-access-key }}
```
Expand Down Expand Up @@ -105,6 +109,7 @@ jobs:
with:
release-identifier: '-pr${{ github.event.number }}-rc'
ecr-name: 'my-app-registry'
github-token: ${{ secrets.GITHUB_TOKEN }}
aws-access-key-id: ${{ secrets.aws-access-key-id }}
aws-secret-access-key: ${{ secrets.aws-secret-access-key }}
```
11 changes: 10 additions & 1 deletion action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ inputs:
release-identifier:
description: 'A string that will be used to identify the releases to be deleted (eg. "pr1234").'
required: true
keep-latest-count:
description: 'The number of matches releases to keep, ordered from latest to oldest.'
required: true
default: '0'
ecr-name:
description: 'The name of an ECR where to look for container images tagged with the releases we are deleting. The name is not the full URL, it is just the last bit of the URL.'
required: false
Expand All @@ -13,6 +17,9 @@ inputs:
s3-object-key-prefix:
description: 'The S3 object key prefix used to look for artefacts tagged with the releases we are deleting.'
required: false
github-token:
description: 'The github token used to delete the releases and tags.'
required: true
aws-access-key-id:
description: 'The AWS access key ID providing access to delete artefacts from either or both ECR and S3 Bucket.'
required: false
Expand All @@ -32,13 +39,15 @@ runs:
steps:
- name: Delete GitHub release candidates
id: delete-github
uses: wow-actions/[email protected]
uses: wow-actions/[email protected].1 # later releases are broken https://github.com/wow-actions/delete-stale-releases/issues/3
with:
key: name
include: '*${{ inputs.release-identifier }}*'
include_prerelease: true
include_draft: true
delete_tags: true
keep_latest_count: ${{ inputs.keep-latest-count }}
github_token: ${{ inputs.github-token }}
- name: Authenticate to AWS
uses: aws-actions/configure-aws-credentials@v1
if: always() && inputs.aws-access-key-id && inputs.aws-secret-access-key
Expand Down