-
Notifications
You must be signed in to change notification settings - Fork 1
67 lines (66 loc) · 2.41 KB
/
pull-request-label-deploy.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
name: Deployment via PR label
on:
pull_request:
types: [labeled]
jobs:
permission:
name: permission check
runs-on: ubuntu-latest
if: github.actor == github.event.repository.owner.login
steps:
- name: check permission
run: echo permission pass
debug:
name: _debug
needs: permission
runs-on: ubuntu-latest
if: contains(github.event.pull_request.labels.*.name, 'debug')
steps:
- name: context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
deployment:
name: Deployment via label
needs: permission
runs-on: ubuntu-latest
if: |
github.event.label.name == 'azure' ||
github.event.label.name == 'gcp' ||
github.event.label.name == 'aws'
steps:
- name: ACK deployment request
uses: actions/[email protected]
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '👋 @' + context.actor + ', deployment request for ${{ github.event.label.name }} received ...'
})
- name: Kicking off deployment
uses: actions/[email protected]
env:
cloud: ${{ github.event.label.name }}
customer: ${{ github.event.pull_request.head.ref }}
with:
github-token: ${{secrets.GPR_PAT}}
script: |
const { cloud, customer } = process.env;
let customerNormalized = customer.replace(/[^a-zA-Z0-9_\-]*/g, '')
let gprUrl='docker.pkg.github.com/'+context.repo.owner.toLowerCase()+'/'+context.repo.repo.toLowerCase()+'/octocat-generator-docker:'+customerNormalized
github.repos.createDeployment({
owner: context.repo.owner,
repo: context.repo.repo,
ref: customerNormalized,
task: 'deploy-to-' + cloud,
auto_merge: false,
required_contexts: [],
environment: cloud + '-' + customerNormalized + '-' + context.issue.number,
description: 'Production environment for ' + customer + ' on ' + cloud,
payload: { customer: customer, cloud: cloud, gprUrl: gprUrl, issue: context.issue.number, customerNormalized: customerNormalized },
production_environment: false,
transient_environment: false
})