-
-
Notifications
You must be signed in to change notification settings - Fork 609
148 lines (127 loc) · 5.64 KB
/
issues.yml
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
name: Automatic Pull Request
on:
issues:
types: [opened, reopened]
env:
SWIFT_IMAGE: swift:6.0.1-jammy
jobs:
add:
runs-on: ubuntu-20.04
if: contains(github.event.issue.labels.*.name, 'Add Package')
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Add Package to JSON
run: docker run --rm -e CI=true -e GH_BODY="$GH_BODY" -v "$PWD:/host" -w /host $SWIFT_IMAGE swift .github/add_package.swift
env:
GH_BODY: ${{ github.event.issue.body }}
- name: Validate JSON
run: docker run --rm -e CI=true -e GITHUB_TOKEN=$GITHUB_TOKEN -v "$PWD:/host" -w /host $SWIFT_IMAGE swift validate.swift
id: validate
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Check for Changes
run: bash .github/check_for_changes.sh
id: check
- name: Create Pull Request
id: cpr
if: steps.check.outputs.changes == 'true'
uses: peter-evans/create-pull-request@v3
with:
add-paths: |
packages.json
commit-message: ${{ github.event.issue.title }}
title: ${{ github.event.issue.title }}
branch: spi-auto-${{ github.event.issue.number }}
delete-branch: true
body: |
Closes #${{ github.event.issue.number }}
## Original Message
${{ github.event.issue.body }}
committer: GitHub <[email protected]>
author: GitHub <[email protected]>
- name: Update Issue (Success)
if: steps.check.outputs.changes == 'true'
uses: actions/github-script@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'Thank you! We will approve and add these packages with #${{ steps.cpr.outputs.pull-request-number }}.'
})
- name: Update Issue (Failure)
if: ${{ failure() || steps.check.outputs.changes != 'true' }}
uses: actions/github-script@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'It looks like there’s nothing to do here!\n\nThe package may [already be in the package list](https://github.com/SwiftPackageIndex/PackageList/blob/main/packages.json) or on the [denylist](https://github.com/SwiftPackageIndex/PackageList/blob/main/denylist.json). Or, if you submitted the wrong URL or there’s a typo, please close this issue and [start a new one](https://github.com/SwiftPackageIndex/PackageList/issues/new/choose).\n\n>Validate Error: ${{ steps.validate.outputs.validateError || 'None' }}'
})
remove:
runs-on: ubuntu-20.04
if: contains(github.event.issue.labels.*.name, 'Remove Package')
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Remove Package from JSON
run: docker run --rm -e CI=true -e GH_BODY="$GH_BODY" -e GH_ISSUE="$GH_ISSUE" -v "$PWD:/host" -w /host $SWIFT_IMAGE swift .github/remove_package.swift
env:
GH_BODY: ${{ github.event.issue.body }}
GH_ISSUE: ${{ github.event.issue.number }}
- name: Validate JSON
run: docker run --rm -e CI=true -e GITHUB_TOKEN=$GITHUB_TOKEN -v "$PWD:/host" -w /host $SWIFT_IMAGE swift validate.swift
id: validate
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Check for Changes
run: bash .github/check_for_changes.sh
id: check
- name: Create Pull Request
id: cpr
if: steps.check.outputs.changes == 'true'
uses: peter-evans/create-pull-request@v3
with:
add-paths: |
packages.json
denylist.json
commit-message: ${{ github.event.issue.title }}
title: ${{ github.event.issue.title }}
branch: spi-auto-${{ github.event.issue.number }}
delete-branch: true
body: |
Closes #${{ github.event.issue.number }}
## Original Message
${{ github.event.issue.body }}
committer: GitHub <[email protected]>
author: GitHub <[email protected]>
- name: Update Issue (Success)
if: steps.check.outputs.changes == 'true'
uses: actions/github-script@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'Thank you! We will approve and remove these packages with #${{ steps.cpr.outputs.pull-request-number }}.'
})
- name: Update Issue (Failure)
if: ${{ failure() || steps.check.outputs.changes != 'true' }}
uses: actions/github-script@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'Oh no! We were unable to detect any valid packages in your submission. If you submitted the wrong URL and would like to update it, please [open a new issue](https://github.com/SwiftPackageIndex/PackageList/issues/new/choose).\n\n>Validate Error: ${{ steps.validate.outputs.validateError || 'None' }}'
})