update versions #26
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Go Build | |
on: | |
push: | |
branches: | |
- main | |
env: | |
PROJECT_ID: ${{ secrets.RUN_PROJECT }} | |
REGION: europe-west4 | |
RUN_REGION: europe-west4 | |
SERVICE_NAME: cmg | |
SERVICE: cmg | |
jobs: | |
test: | |
name: Test | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- uses: actions/setup-go@v1 | |
with: | |
stable: 'false' | |
go-version: '^1.16' | |
- name: check go version | |
run: go version | |
- name: get dependency | |
run: go get -t -v ./... | |
- name: gofmt | |
run: gofmt -s -w -l **/*.go | |
- name: test | |
run: make test | |
tag: | |
name: Create Tag & Release | |
needs: [test] | |
runs-on: ubuntu-20.04 | |
outputs: | |
tag: ${{ steps.version_bump.outputs.new_tag }} | |
steps: | |
- uses: actions/checkout@master | |
- id: version_bump | |
name: Bump version and push tag | |
uses: anothrNick/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
WITH_V: false | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@latest | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token | |
with: | |
tag_name: v${{steps.version_bump.outputs.new_tag}} | |
release_name: Release ${{steps.version_bump.outputs.new_tag}} | |
sonarCloudTrigger: | |
name: SonarCloud Trigger | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@master | |
- name: SonarCloud Scan | |
uses: sonarsource/sonarcloud-github-action@master | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
cloud-run: | |
name: Google Cloud Run | |
runs-on: ubuntu-20.04 | |
needs: tag | |
steps: | |
- name: 'Checkout' | |
uses: 'actions/checkout@v2' | |
- id: 'auth' | |
uses: 'google-github-actions/auth@v0' | |
with: | |
credentials_json: '${{ secrets.RUN_SA_KEY }}' | |
- name: 'Set up Cloud SDK' | |
uses: 'google-github-actions/setup-gcloud@v0' | |
- name: 'Build' | |
run: 'gcloud builds submit --tag gcr.io/$PROJECT_ID/$SERVICE_NAME:${{needs.tag.outputs.tag}}' | |
- name: 'Deploy to Cloud Run' | |
uses: 'google-github-actions/deploy-cloudrun@v0' | |
with: | |
service: '${{ env.SERVICE }}' | |
image: 'gcr.io/${{ env.PROJECT_ID }}/${{ env.SERVICE }}:${{needs.tag.outputs.tag}}' | |
region: '${{ env.REGION }}' |