-
-
Notifications
You must be signed in to change notification settings - Fork 0
88 lines (76 loc) · 2.75 KB
/
test-positive.yml
File metadata and controls
88 lines (76 loc) · 2.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
name: Test Positive
on:
workflow_dispatch: {}
permissions:
contents: write
pull-requests: write
jobs:
setup:
runs-on: ubuntu-latest
steps:
- name: Setup
run: echo "Do setup"
create-release:
runs-on: ubuntu-latest
continue-on-error: true
needs: [setup]
steps:
- name: Checkout
uses: actions/checkout@v3
- id: create-release
run: |
release_name="${PREFIX}$(git rev-parse --short HEAD)"
gh release create ${release_name} --prerelease --target ${{ github.sha }} --notes "Created by ${{ github.workflow }} (will be automatically deleted)."
echo "name=${release_name}" > $GITHUB_OUTPUT
echo "tag=$(gh release view ${release_name} --json tagName -q '.tagName')" >> $GITHUB_OUTPUT
env:
# Below is the main difference between this workflow's negative counterpart.
# The action _will_ pick up a comment because the provided 'include_regex' will be able to match it.
PREFIX: "v0.0.0-test.include."
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
outputs:
name: ${{ steps.create-release.outputs.name }}
tag: ${{ steps.create-release.outputs.tag }}
assert:
runs-on: ubuntu-latest
needs: [create-release]
outputs:
comment-id: ${{ steps.fc.outputs.comment-id }}
steps:
- uses: actions/checkout@v4
- uses: ./
id: action
with:
tag: ${{ needs.create-release.outputs.tag }}
include_regex: 'v0\.0\.0-test\.include\..*' # Should find a comment
- name: debug
run: |
echo "${{ fromJSON(steps.action.outputs.result) }}"
- name: Find Comment
uses: peter-evans/find-comment@v3
id: fc
with:
issue-number: ${{ fromJSON(steps.action.outputs.result).comments[0].pull_request }}
body-includes: ${{ needs.create-release.outputs.tag }}
teardown:
runs-on: ubuntu-latest
needs: [create-release, assert]
if: ${{ always() }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Delete Test Release + Tag
if: needs.create-release.result == 'success'
run: gh release delete ${{ needs.create-release.outputs.name }} --cleanup-tag
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: octokit/request-action@v2.x
name: Delete Test Release Comment
if: ${{ always() && needs.assert.outputs.comment-id != 0 }}
with:
route: DELETE /repos/{owner}/{repo}/issues/comments/{comment_id}
owner: "${{ github.event.repository.owner.login }}"
repo: "${{ github.event.repository.name }}"
comment_id: ${{ needs.assert.outputs.comment-id }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}