Skip to content
This repository has been archived by the owner on Sep 24, 2020. It is now read-only.

Commit

Permalink
Make dev docker tag changes (#90)
Browse files Browse the repository at this point in the history
* Make dev docker tag changes

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

* finish hooks and add chatops

* finish hooks and add chatops

Co-authored-by: ras-rm-bot <[email protected]>
  • Loading branch information
jterryons and ras-rm-bot authored Jun 7, 2020
1 parent 6a1566e commit 6c56862
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 14 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/comment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: comment

on:
issue_comment:
types: [created]

env:
IMAGE: notify-gateway
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 ::set-env name=NAMESPACE::$(echo ${{ github.event.comment.body }} | cut -d' ' -f2)
- 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.issue.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\": \"sandbox\", \"actor\": \"$GITHUB_ACTOR\" } }" \
--attribute ci="actions"
49 changes: 36 additions & 13 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ on:
branches: [ master ]

env:
GITHUB_SHA: ${{ github.sha }}
GITHUB_REF: ${{ github.ref }}
IMAGE: notify-gateway
REGISTRY_HOSTNAME: eu.gcr.io
HOST: ${{ secrets.GOOGLE_PROJECT_ID }}
RELEASE_HOST: ${{ secrets.RELEASE_PROJECT_ID }}
CHART_DIRECTORY: _infra/helm/notify-gateway
SPINNAKER_TOPIC: ${{ secrets.SPINNAKER_TOPIC }}
ARTIFACT_BUCKET: ${{ secrets.ARTIFACT_BUCKET }}

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
Expand Down Expand Up @@ -50,16 +50,38 @@ jobs:
# Configure docker to use the gcloud command-line tool as a credential helper
- run: |
gcloud auth configure-docker
- name: pr docker tag
if: github.ref != 'refs/heads/master'
id: tag
run: |
PR=$(echo "$GITHUB_REF" | awk -F / '{print $3}')
echo "$PR"
echo ::set-output name=pr_number::pr-"$PR"
# Build the Docker image
- name: Build Docker Image
if: github.ref != 'refs/heads/master'
run: |
docker build -t "$REGISTRY_HOSTNAME"/"$HOST"/"$IMAGE":$GITHUB_SHA .
docker build -t "$REGISTRY_HOSTNAME"/"$HOST"/"$IMAGE":${{ steps.tag.outputs.pr_number }} .
- name: Push dev image
if: github.ref != 'refs/heads/master'
run: |
docker push "$REGISTRY_HOSTNAME"/"$HOST"/"$IMAGE":$GITHUB_SHA
docker push "$REGISTRY_HOSTNAME"/"$HOST"/"$IMAGE":${{ steps.tag.outputs.pr_number }}
- name: template helm
run: |
helm template _infra/helm/notify-gateway
helm template $CHART_DIRECTORY
- name: package helm
run: |
echo ::set-env name=HELM_VERSION::$(grep -E "version:\s+" $CHART_DIRECTORY/Chart.yaml | cut -d" " -f2 | sed -r 's/"//g')
helm dep up $CHART_DIRECTORY
helm package $CHART_DIRECTORY
- name: Publish dev Chart
if: github.ref != 'refs/heads/master'
run: |
mv $IMAGE-${{ env.HELM_VERSION }}.tgz $IMAGE-latest.tgz
gsutil cp $IMAGE-*.tgz gs://$ARTIFACT_BUCKET/$IMAGE/
- name: Set current tag
if: github.ref != 'refs/heads/master'
Expand Down Expand Up @@ -114,12 +136,6 @@ jobs:
run: |
echo ::set-output name=version::$(grep -E "appVersion:\s+" $CHART_DIRECTORY/Chart.yaml | cut -d" " -f2 | sed -r 's/"//g')
- name: package helm
if: github.ref == 'refs/heads/master'
run: |
helm dep up _infra/helm/notify-gateway
helm package _infra/helm/notify-gateway
- name: Build Release Image
if: github.ref == 'refs/heads/master'
run: |
Expand All @@ -132,7 +148,7 @@ jobs:
- name: Publish Charts
if: github.ref == 'refs/heads/master'
run: |
gsutil cp notify-gateway-*.tgz gs://ras-rm-artifacts/notify-gateway/
gsutil cp $IMAGE-*.tgz gs://$ARTIFACT_BUCKET/$IMAGE/
- uses: actions/create-release@v1
if: github.ref == 'refs/heads/master'
Expand All @@ -145,4 +161,11 @@ jobs:
Automated release
${{ steps.release.outputs.version }}
draft: false
prerelease: false
prerelease: false

- name: CD hook
if: github.ref == 'refs/heads/master'
run: |
gcloud pubsub topics publish $SPINNAKER_TOPIC --project $HOST \
--message "{ \"kind\": \"storage#object\", \"name\": \"$IMAGE/$IMAGE-${{ env.HELM_VERSION }}.tgz\", \"bucket\": \"$ARTIFACT_BUCKET\" }" \
--attribute cd="actions"
2 changes: 1 addition & 1 deletion _infra/helm/notify-gateway/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ version: 1.2.1

# 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.15
appVersion: 11.0.16

0 comments on commit 6c56862

Please sign in to comment.