v3.2.3 #14
Workflow file for this run
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: Deploy API service | |
on: | |
push: | |
tags: | |
- v* | |
jobs: | |
vars: | |
runs-on: ubuntu-latest | |
steps: | |
- id: tag_version | |
run: echo ::set-output name=VERSION::$(echo $GITHUB_REF | cut -d / -f 3) | |
outputs: | |
version: ${{ steps.tag_version.outputs.VERSION }} | |
image: ${{ github.repository }}-api:${{ steps.tag_version.outputs.VERSION }} | |
build: | |
needs: [vars] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- uses: docker/build-push-action@v2 | |
id: docker_build | |
with: | |
context: . | |
push: true | |
file: api/Dockerfile | |
tags: ${{ needs.vars.outputs.image }} | |
- | |
name: Image digest | |
run: echo ${{ steps.docker_build.outputs.digest }} | |
deploy: | |
runs-on: ubuntu-latest | |
needs: [vars, build] | |
steps: | |
- uses: 8398a7/action-slack@v3 | |
with: | |
status: custom | |
fields: repo,ref,author | |
custom_payload: | | |
{ | |
attachments: [{ | |
color: '#1d9bd1', | |
text: `Deployment of ${process.env.AS_REPO}@${process.env.AS_REF} by ${process.env.AS_AUTHOR} has started.`, | |
}] | |
} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |
- name: Deploy to Kubernetes | |
run: npx @endeavorb2b/rancher2cli dl most-popular-service api ${{ needs.vars.outputs.image }} | |
env: | |
RANCHER_CLUSTERID: ${{ secrets.RANCHER_CLUSTERID_BASECMS }} | |
RANCHER_TOKEN: ${{ secrets.RANCHER_TOKEN }} | |
RANCHER_URL: ${{ secrets.RANCHER_URL }} | |
- uses: 8398a7/action-slack@v3 | |
with: | |
status: custom | |
fields: repo,ref,author,took | |
if: always() | |
custom_payload: | | |
{ | |
attachments: [{ | |
color: '${{ job.status }}' === 'success' ? 'good' : '${{ job.status }}' === 'failure' ? 'danger' : 'warning', | |
text: `Deployment of ${process.env.AS_REPO}@${process.env.AS_REF} by ${process.env.AS_AUTHOR} ${{ job.status }} in ${process.env.AS_TOOK}`, | |
}] | |
} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} |