Skip to content

Commit

Permalink
new comment action (#227)
Browse files Browse the repository at this point in the history
* new comment action

* [ci skip] auto patch increment
skip-checks: true

Co-authored-by: ras-rm-pr-bot <[email protected]>
  • Loading branch information
jterryons and ras-rm-pr-bot authored Dec 24, 2020
1 parent 352d4bc commit 000a054
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 36 deletions.
48 changes: 13 additions & 35 deletions .github/workflows/comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,46 +5,24 @@ on:
types: [created]

env:
IMAGE: collection-exercise
SPINNAKER_TOPIC: ${{ secrets.SPINNAKER_TOPIC }}
ARTIFACT_BUCKET: ${{ secrets.ARTIFACT_BUCKET }}
HOST: ${{ secrets.GOOGLE_PROJECT_ID }}
SERVICE: collection-exercise

jobs:
comment:
runs-on: ubuntu-latest
if: contains(github.event.comment.body, '/deploy')
steps:
- name: set namespace
env:
COMMENT_BODY: ${{ github.event.comment.body }}
run: |
echo NAMESPACE=$(echo $COMMENT_BODY | cut -d' ' -f2) >> $GITHUB_ENV
PARAM_KV_PAIR=$(echo $COMMENT_BODY | cut -d' ' -f3)
IFS='='
arrIN=($PARAM_KV_PAIR)
echo PARAM_KEY=${arrIN[0]} >> $GITHUB_ENV
echo PARAM_VALUE=${arrIN[1]} >> $GITHUB_ENV
unset IFS
- uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
- uses: google-github-actions/setup-gcloud@master
with:
version: '270.0.0'
project_id: ${{ secrets.GOOGLE_PROJECT_ID }}
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\", \"paramKey\": \"PARAM_KEY\", \"paramValue\": \"$PARAM_VALUE\" } }" \
--attribute ci="actions"
export_default_credentials: true

- uses: onsdigital/ras-rm-spinnaker-action@main
with:
comment-body: ${{ github.event.comment.body }}
gcp-project: ${{ secrets.GOOGLE_PROJECT_ID }}
bot-token: ${{ secrets.BOT_TOKEN }}
spinnaker-topic: ${{ secrets.SPINNAKER_TOPIC }}
artifact-bucket: ${{ secrets.ARTIFACT_BUCKET }}
helm-chart: ${{ env.SERVICE }}/${{ env.SERVICE }}-latest.tgz
2 changes: 1 addition & 1 deletion _infra/helm/collection-exercise/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ version: 1.2.2

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application.
appVersion: 11.0.33
appVersion: 11.0.34

0 comments on commit 000a054

Please sign in to comment.