Deploy to production #45
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 to production | |
on: | |
workflow_dispatch: | |
concurrency: | |
group: deploy_to_prod | |
cancel-in-progress: false | |
jobs: | |
deploy: | |
name: Deploy to production | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
environment: ["production"] | |
service: ["app", "backend", "hasura"] | |
environment: | |
name: ${{ matrix.environment }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Install Scalingo CLI | |
uses: ./.github/actions/scalingo-cli | |
- name: Deploy on Scalingo | |
env: | |
SCALINGO_REGION: ${{ secrets.SCALINGO_REGION }} | |
SCALINGO_APP: cdb-${{ matrix.service }}${{ secrets.APP_SUFFIX }} | |
SCALINGO_API_TOKEN: ${{ secrets.SCALINGO_API_TOKEN }} | |
run: | |
scalingo deploy ${{ github.server_url }}/${{ github.repository }}/tarball/${{ github.ref_name }} ${{ github.ref_name }} | |
notify: | |
name: Notify | |
runs-on: ubuntu-latest | |
needs: [deploy] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Find last deployed commit | |
uses: SamhammerAG/last-successful-build-action@1c368a27a90596574a71ac0ede422a897d0e8e84 | |
id: latest-deployment | |
with: | |
token: "${{ secrets.GITHUB_TOKEN }}" | |
workflow: "Deploy to production" | |
verify: true | |
- name: Post message with changelog contents | |
run: | | |
CHANGELOG_CONTENT=$(git diff --output-indicator-new='*' ${{ steps.latest-deployment.outputs.sha }}...${{ github.sha }} CHANGELOG.md | egrep '^\*' | cut -c 2-) | |
MESSAGE_JSON=$(node -p 'JSON.stringify({text:`:tada: **${{ github.ref_name }} en production**\n${process.argv[1]}`})' "$CHANGELOG_CONTENT") | |
curl -Ss ${{ secrets.MATTERMOST_WEBHOOK_URL }} -H 'Content-Type:application/json' --data-binary "$MESSAGE_JSON" |