Skip to content

Commit

Permalink
v3 (#800)
Browse files Browse the repository at this point in the history
* convert to composite action

* refactor
  • Loading branch information
peter-evans authored Apr 6, 2023
1 parent b1c15b9 commit 3cd3bb0
Show file tree
Hide file tree
Showing 16 changed files with 68 additions and 24,324 deletions.
3 changes: 0 additions & 3 deletions .eslintignore

This file was deleted.

18 changes: 0 additions & 18 deletions .eslintrc.json

This file was deleted.

12 changes: 0 additions & 12 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,3 @@ updates:
day: "wednesday"
labels:
- "dependencies"

- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
day: "wednesday"
ignore:
- dependency-name: "*"
update-types: ["version-update:semver-major"]
labels:
- "dependencies"

56 changes: 7 additions & 49 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16.x
cache: npm
- run: npm ci
- run: npm run build
- run: npm run format-check
- run: npm run lint
- run: npm run test
- uses: actions/upload-artifact@v3
with:
name: dist
path: dist
- uses: actions/upload-artifact@v3
with:
name: action.yml
Expand All @@ -42,61 +29,32 @@ jobs:
test:
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
needs: [build]
runs-on: ubuntu-latest
strategy:
matrix:
target: [built, committed]
os: [windows-latest, ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- if: matrix.target == 'built' || github.event_name == 'pull_request'
uses: actions/download-artifact@v3
with:
name: dist
path: dist
- if: matrix.target == 'built' || github.event_name == 'pull_request'
uses: actions/download-artifact@v3
- uses: actions/download-artifact@v3
with:
name: action.yml
path: .

- name: Create issue content
run: echo "#[CI] test ${{ matrix.target }}" > issue.md
run: echo "#[CI] test ${{ matrix.os }}" > issue.md

- name: Test create issue from file
id: ciff
uses: peter-evans/create-issue-from-file@v4
with:
title: '[CI] test ${{ matrix.target }}'
title: '[CI] test ${{ matrix.os }}'
content-filepath: ./issue.md

- name: Close Issue
uses: ./
with:
issue-number: ${{ steps.ciff.outputs.issue-number }}
comment: '[CI] test ${{ matrix.target }}'
comment: '[CI] test ${{ matrix.os }}'
labels: |
wontfix
package:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs: [test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: dist
path: dist
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.ACTIONS_BOT_TOKEN }}
commit-message: Update distribution
title: Update distribution
body: |
- Updates the distribution for changes on `main`
Auto-generated by [create-pull-request][1]
[1]: https://github.com/peter-evans/create-pull-request
branch: update-distribution
ci-test
1 change: 1 addition & 0 deletions .github/workflows/update-major-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:
description: The major version tag to update
options:
- v2
- v3

jobs:
tag:
Expand Down
2 changes: 0 additions & 2 deletions .gitignore

This file was deleted.

3 changes: 0 additions & 3 deletions .prettierignore

This file was deleted.

11 changes: 0 additions & 11 deletions .prettierrc.json

This file was deleted.

20 changes: 15 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,21 @@ A GitHub action to close an issue.

## Usage

| :exclamation: Using this action is no longer necessary |
|-----------------------------------------------------------|

The same functionality exists in the GitHub CLI. See the documentation [here](https://cli.github.com/manual/gh_issue_close).
```yml
- name: Close Issue
run: gh issue close --comment "Auto-closing issue" "1"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```
If you prefer to use this action:
```yml
- name: Close Issue
uses: peter-evans/close-issue@v2
uses: peter-evans/close-issue@v3
with:
issue-number: 1
comment: Auto-closing issue
Expand All @@ -28,7 +40,7 @@ jobs:
steps:
- if: startsWith(github.event.issue.title, 'ABC-') != 'true'
name: Close Issue
uses: peter-evans/close-issue@v2
uses: peter-evans/close-issue@v3
with:
comment: |
Issue title must start with 'ABC-'.
Expand All @@ -38,16 +50,14 @@ jobs:
### Close issue and add label(s)
```yml
- name: Close Issue
uses: peter-evans/close-issue@v2
uses: peter-evans/close-issue@v3
with:
issue-number: 1
comment: Auto-closing issue
labels: |
wontfix
```
> Add multiple labels separated by comma
### Action inputs
| Name | Description | Default |
Expand Down
48 changes: 45 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,50 @@ inputs:
required: false
description: 'A comma or newline separated list of labels.'
runs:
using: 'node16'
main: 'dist/index.js'
using: composite
steps:
- name: Set parameters
id: params
shell: bash
run: |
if [ -n "${{ inputs.comment }}" ]; then
echo comment="--comment \"${{ inputs.comment }}\"" >> $GITHUB_OUTPUT
fi
if [ "${{ inputs.close-reason }}" == "not_planned" ]; then
echo close-reason="not planned" >> $GITHUB_OUTPUT
else
echo close-reason="completed" >> $GITHUB_OUTPUT
fi
# Convert labels to comma separated list
if [ -n "${{ inputs.labels }}" ]; then
labels=$(echo "${{ inputs.labels }}" | tr '\n' ',' | sed 's/,$//')
# Remove trailing comma and whitespace
labels=$(echo $labels | sed 's/,$//' | sed 's/[[:space:]]//g')
echo labels=$labels >> $GITHUB_OUTPUT
fi
- name: Close Issue
shell: bash
run: |
gh issue close -R "${{ inputs.repository }}" \
--reason "${{ steps.params.outputs.close-reason }}" \
${{ steps.params.outputs.comment }} \
"${{ inputs.issue-number }}"
env:
GH_TOKEN: ${{ inputs.token }}

- name: Add Labels
if: steps.params.outputs.labels != ''
shell: bash
run: |
gh issue edit -R "${{ inputs.repository }}" \
--add-label "${{ steps.params.outputs.labels }}" \
"${{ inputs.issue-number }}"
env:
GH_TOKEN: ${{ inputs.token }}

branding:
icon: 'slash'
icon: 'git-pull-request'
color: 'gray-dark'
Loading

0 comments on commit 3cd3bb0

Please sign in to comment.