-
Notifications
You must be signed in to change notification settings - Fork 2
42 lines (36 loc) · 1.58 KB
/
main.yml
File metadata and controls
42 lines (36 loc) · 1.58 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
name: comment
on:
issue_comment:
types: [created]
env:
IMAGE: uaa
SPINNAKER_TOPIC: ${{ secrets.SPINNAKER_TOPIC }}
ARTIFACT_BUCKET: ${{ secrets.ARTIFACT_BUCKET }}
HOST: ${{ secrets.GOOGLE_PROJECT_ID }}
jobs:
comment:
runs-on: ubuntu-latest
if: contains(github.event.comment.body, '/deploy')
steps:
- name: set namespace
run: |
echo NAMESPACE=$(echo ${{ github.event.comment.body }} | cut -d' ' -f2) >> $GITHUB_ENV
- uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
with:
version: '270.0.0'
service_account_key: ${{ secrets.GCR_KEY }}
- run: |
gcloud auth configure-docker
- uses: actions/checkout@v1
- name: Add commit comment
run: |
jq -nc "{\"body\": \"@${{ github.event.comment.user.login }}, Spinnaker is deploying the PR to your environment\"}" | \
curl -sL -X POST -d @- \
-H "Content-Type: application/json" \
-H "Authorization: token ${{ secrets.BOT_TOKEN }}" \
"https://api.github.com/repos/$GITHUB_REPOSITORY/issues/${{ github.event.issue.number }}/comments"
- name: Trigger spinnaker
run: |
gcloud pubsub topics publish $SPINNAKER_TOPIC --project $HOST \
--message "{ \"kind\": \"storage#object\", \"name\": \"$IMAGE/$IMAGE-latest.tgz\", \"bucket\": \"$ARTIFACT_BUCKET\", \"parameters\": { \"tag\": \"pr-${{ github.event.issue.number }}\", \"namespace\": \"${{ env.NAMESPACE }}\", \"cluster\": \"dev\", \"actor\": \"$GITHUB_ACTOR\" } }" \
--attribute ci="actions"