Skip to content

source_documentation_change #2705

source_documentation_change

source_documentation_change #2705

name: Publish production
# Allow only one running and one pending instance of this workflow. See https://github.com/bonitasoft/bonita-documentation-site/issues/192
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-only-cancel-in-progress-jobs-or-runs-for-the-current-workflow
concurrency: ${{ github.workflow }}
on:
repository_dispatch:
types: [source_documentation_change]
workflow_dispatch:
inputs:
branch:
required: false
description: "Branch of component"
component:
required: false
description: "Name of component which triggers the build"
push:
branches:
- master
paths:
- ".github/actions/build-setup/**/*"
- ".github/workflows/publish-production.yml"
- ".nvmrc"
- "resources/**/*"
- "antora-playbook.yml"
- "netlify.toml"
- "package.json"
- "package-lock.json"
permissions:
# netlify: notify deployments
deployments: write
jobs:
deploy_to_netlify:
runs-on: ubuntu-22.04
env:
GOOGLE_ANALYTICS_KEY: GTM-TXHBK7
COMPONENT: ${{ github.event.client_payload.component || github.event.inputs.component }}
BRANCH: ${{ github.event.client_payload.branch || github.event.inputs.branch }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build Setup
uses: ./.github/actions/build-setup
- name: Build site
run: GOOGLE_ANALYTICS_KEY=${{env.GOOGLE_ANALYTICS_KEY}} npm run build
- name: Prepare site manifest
run: gzip build/site/site-manifest.json
- name: List the content of the generated site
uses: ./.github/actions/log-built-site-details
- name: Create deploy message if no component defined
if: ( github.event_name == 'workflow_dispatch' || github.event_name == 'repository_dispatch' ) && env.COMPONENT == ''
run: echo "deploy_message=Deploy ${{github.sha}} from manual request" >> $GITHUB_ENV
- name: Create deploy message if component defined
if: ( github.event_name == 'workflow_dispatch' || github.event_name == 'repository_dispatch' ) && env.COMPONENT != ''
run: echo "deploy_message=Deploy ${{ env.COMPONENT }} ${{ env.BRANCH }} update" >> $GITHUB_ENV
- name: Create deploy message if push or pull request
if: github.event_name == 'push'
run: echo "deploy_message=Deploy ${{ github.sha }}" >> $GITHUB_ENV
- name: Deploy to Netlify
uses: nwtgck/[email protected]
with:
publish-dir: "./build/site"
production-deploy: true
github-token: ${{ secrets.GITHUB_TOKEN }}
deploy-message: ${{ env.deploy_message }}
netlify-config-path: ./netlify.toml
# let us detect when secrets are not available when attempting to push to production
fails-without-credentials: true
github-deployment-description: ${{ env.deploy_message }}
# no comment nor commit status, we only publish to production, the publishing information is available with the github environment
enable-pull-request-comment: false
enable-commit-comment: false
enable-commit-status: false
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
timeout-minutes: 10
- name: Send message to Slack channel
if: failure()
uses: bonitasoft/notify-slack-action@v1
with:
keeper-secret-config: ${{ secrets.KSM_CONFIG }}
channel-id: ${{ vars.RD_PLATFORM_SLACK_CHANNEL_ID }}
message: |
:red_circle: Publish documentation in production failed.
@channel *We need someone* !