-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (70 loc) · 2.81 KB
/
create-repo.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
# Workflow to trigger repository creation
name: Create repo
on:
issues:
types: [opened]
jobs:
create-repository:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
steps:
# Checkout the repository to have access to the custom actions used
- uses: actions/checkout@v3
# We need to authenticate with an App token to check out the private (custom actions)
- name: Retrieve the admin token
id: github_app
uses: machine-learning-apps/actions-app-token@0.21
with:
APP_PEM: ${{ secrets.APP_PRIVATE_KEY }}
APP_ID: ${{ secrets.APP_ID }}
# Retrieve the request information from the submitted Issue
- name: Parse the issue
id: parser
uses: ./.github/actions/issue-parser
with:
admin_token: ${{ steps.github_app.outputs.app_token }}
# Comment on the Issue to let the user know that their request has been received
- name: Greetings for the users submitting issues to this repository
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `
👋 Thanks for opening this issue to create the repository '${{ steps.parser.outputs.name }}'!
Hang on for a moment while we do the checks and you will be notified in this issue when everything is ready.
`
})
# Create the repository
- name: Create capability repository
id: create_repository
uses: ./.github/actions/repo-creator
with:
repository_name: ${{ steps.parser.outputs.name }}
admin_token: ${{ steps.github_app.outputs.app_token }}
# Add a new comment on the Issue to let the user know that their request was processed and then close the Issue
- uses: actions/github-script@v6
name: Report created elements
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `
OK @${context.payload.sender.login}, we are finished!
The new repository created is: **${{ steps.create_repository.outputs.repository_name }}**
We are now closing this issue.
`
})
github.rest.issues.update({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
state: 'closed'
})