create-or-update-comment/.github/workflows/ci.yml

134 lines
3.6 KiB
YAML
Raw Normal View History

2020-05-01 18:10:35 +08:00
name: CI
on:
push:
2021-05-12 16:18:15 +08:00
branches: [main]
2020-05-06 10:45:41 +08:00
paths-ignore:
- 'README.md'
- 'docs/**'
2020-05-01 18:10:35 +08:00
pull_request:
2021-05-12 16:18:15 +08:00
branches: [main]
2020-05-06 10:45:41 +08:00
paths-ignore:
- 'README.md'
- 'docs/**'
2022-08-19 10:21:32 +08:00
permissions:
issues: write
pull-requests: write
contents: write
2020-05-01 18:10:35 +08:00
jobs:
build:
runs-on: ubuntu-latest
outputs:
issue-number: ${{ steps.vars.outputs.issue-number }}
steps:
2022-03-22 13:58:13 +08:00
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
2020-05-01 18:10:35 +08:00
with:
2022-03-22 13:58:13 +08:00
node-version: 16.x
2022-12-09 16:07:54 +08:00
cache: npm
2020-05-01 18:10:35 +08:00
- run: npm ci
- run: npm run test
- run: npm run package
2022-03-22 13:58:13 +08:00
- uses: actions/upload-artifact@v3
2020-05-01 18:10:35 +08:00
with:
name: dist
path: dist
2022-03-22 13:58:13 +08:00
- uses: actions/upload-artifact@v3
2020-06-02 17:33:54 +08:00
with:
name: action.yml
path: action.yml
2020-05-01 18:10:35 +08:00
- id: vars
run: |
if [[ "${{ github.event_name }}" == "pull_request" ]]; then \
2022-10-18 15:56:13 +08:00
echo "issue-number=${{ github.event.number }}" >> $GITHUB_OUTPUT; \
2020-05-01 18:10:35 +08:00
else \
2022-10-18 15:56:13 +08:00
echo "issue-number=1" >> $GITHUB_OUTPUT; \
2020-05-01 18:33:30 +08:00
fi
2020-05-01 18:10:35 +08:00
test:
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
2020-05-01 18:10:35 +08:00
needs: [build]
runs-on: ubuntu-latest
strategy:
matrix:
target: [built, committed]
steps:
2022-03-22 13:58:13 +08:00
- uses: actions/checkout@v3
2020-05-03 10:51:07 +08:00
- if: matrix.target == 'built' || github.event_name == 'pull_request'
2022-03-22 13:58:13 +08:00
uses: actions/download-artifact@v3
2020-05-01 18:10:35 +08:00
with:
name: dist
path: dist
2020-06-02 17:33:54 +08:00
- if: matrix.target == 'built' || github.event_name == 'pull_request'
2022-03-22 13:58:13 +08:00
uses: actions/download-artifact@v3
2020-06-02 17:33:54 +08:00
with:
name: action.yml
path: .
2020-05-01 18:10:35 +08:00
- name: Test create comment
uses: ./
id: couc
with:
issue-number: ${{ needs.build.outputs.issue-number }}
body: |
This is a multi-line test comment
2020-06-08 07:38:27 +08:00
- With GitHub **Markdown** :sparkles:
2020-05-01 18:10:35 +08:00
- Created by [create-or-update-comment][1]
[1]: https://github.com/peter-evans/create-or-update-comment
reactions: '+1'
- name: Test update comment
uses: ./
with:
comment-id: ${{ steps.couc.outputs.comment-id }}
body: |
**Edit:** Some additional info
reactions: eyes
- name: Test add reactions
uses: ./
with:
comment-id: ${{ steps.couc.outputs.comment-id }}
reactions: heart, hooray, laugh
- name: Test create comment from file
uses: ./
id: couc2
with:
issue-number: ${{ needs.build.outputs.issue-number }}
body-file: .github/comment-body.md
reactions: '+1'
- name: Test update comment from file
uses: ./
with:
comment-id: ${{ steps.couc2.outputs.comment-id }}
2022-10-24 14:42:45 +08:00
body-file: .github/comment-body-addition.md
reactions: eyes
2020-05-01 18:10:35 +08:00
package:
2021-05-12 16:18:15 +08:00
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
2020-05-01 18:10:35 +08:00
needs: [test]
runs-on: ubuntu-latest
steps:
2022-03-22 13:58:13 +08:00
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
2020-05-01 18:10:35 +08:00
with:
name: dist
path: dist
- name: Create Pull Request
uses: peter-evans/create-pull-request@v4
2020-05-01 18:10:35 +08:00
with:
2022-12-09 16:11:52 +08:00
token: ${{ secrets.ACTIONS_BOT_TOKEN }}
2020-05-01 18:10:35 +08:00
commit-message: Update distribution
title: Update distribution
body: |
2021-05-12 16:18:15 +08:00
- Updates the distribution for changes on `main`
2020-05-01 18:10:35 +08:00
Auto-generated by [create-pull-request][1]
[1]: https://github.com/peter-evans/create-pull-request
branch: update-distribution