From 9d9660ec746e5ca3ab561b72a1dc4b1b54945974 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Ott?= Date: Wed, 14 Aug 2024 11:44:37 +0200 Subject: [PATCH] Switch between regular and scheduled channel --- .../workflows/universal_workflow_light.yaml | 24 +++++++++++++------ .../workflows/universal_workflow_light.yml | 24 +++++++++++++------ 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/.github/workflows/universal_workflow_light.yaml b/.github/workflows/universal_workflow_light.yaml index fc049ee5..b4ec0434 100644 --- a/.github/workflows/universal_workflow_light.yaml +++ b/.github/workflows/universal_workflow_light.yaml @@ -40,10 +40,10 @@ on: description: 'Content of ~/oxid-esales/_custom.yaml' default: '' required: false - custom_slack_channel: - type: string - description: 'Custom slack channel to override the default' - default: '' + use_scheduled_slack_channel: + type: boolean + description: 'Use alternative slack channel' + default: false required: false secrets: @@ -71,6 +71,9 @@ on: SLACK_WEBHOOK_URL: required: false # description: Webhook for posting to SLACK + SLACK_SCHEDULED_WEBHOOK_URL: + required: false + # description: Webhook for posting to SLACK jobs: init: @@ -1304,15 +1307,22 @@ jobs: - yamllint - actionlint runs-on: ${{ fromJSON(inputs.runs_on) }} - env: - SLACK_WEBHOOK: "${{ inputs.custom_slack_channel || secrets.SLACK_WEBHOOK_URL }}" steps: + - name: Choose Slack channel + id: slack + shell: bash + run: | + if [ "${{ inputs.use_scheduled_slack_channel }}" == "false" ]; then + echo "webhook=${{ secrets.SLACK_WEBHOOK_URL }}" >>"${GITHUB_OUTPUT}" + else + echo "webhook=${{ secrets.SLACK_SCHEDULED_WEBHOOK_URL }}" >>"${GITHUB_OUTPUT}" + fi - name: 'Generate report' id: generate_report uses: 'OXID-eSales/github-actions/generate_report@v4' with: prefix: '${{ needs.init.outputs.global_title }}' - slack_webhook: ${{ secrets.SLACK_WEBHOOK_URL }} + slack_webhook: ${{ steps.slack.outputs.webhook }} title: '${{ needs.init.outputs.finish_slack_title }}' compact: '${{ needs.init.outputs.finish_slack_compact }}' debug: ${{ inputs.debug }} diff --git a/.github/workflows/universal_workflow_light.yml b/.github/workflows/universal_workflow_light.yml index fc049ee5..b4ec0434 100644 --- a/.github/workflows/universal_workflow_light.yml +++ b/.github/workflows/universal_workflow_light.yml @@ -40,10 +40,10 @@ on: description: 'Content of ~/oxid-esales/_custom.yaml' default: '' required: false - custom_slack_channel: - type: string - description: 'Custom slack channel to override the default' - default: '' + use_scheduled_slack_channel: + type: boolean + description: 'Use alternative slack channel' + default: false required: false secrets: @@ -71,6 +71,9 @@ on: SLACK_WEBHOOK_URL: required: false # description: Webhook for posting to SLACK + SLACK_SCHEDULED_WEBHOOK_URL: + required: false + # description: Webhook for posting to SLACK jobs: init: @@ -1304,15 +1307,22 @@ jobs: - yamllint - actionlint runs-on: ${{ fromJSON(inputs.runs_on) }} - env: - SLACK_WEBHOOK: "${{ inputs.custom_slack_channel || secrets.SLACK_WEBHOOK_URL }}" steps: + - name: Choose Slack channel + id: slack + shell: bash + run: | + if [ "${{ inputs.use_scheduled_slack_channel }}" == "false" ]; then + echo "webhook=${{ secrets.SLACK_WEBHOOK_URL }}" >>"${GITHUB_OUTPUT}" + else + echo "webhook=${{ secrets.SLACK_SCHEDULED_WEBHOOK_URL }}" >>"${GITHUB_OUTPUT}" + fi - name: 'Generate report' id: generate_report uses: 'OXID-eSales/github-actions/generate_report@v4' with: prefix: '${{ needs.init.outputs.global_title }}' - slack_webhook: ${{ secrets.SLACK_WEBHOOK_URL }} + slack_webhook: ${{ steps.slack.outputs.webhook }} title: '${{ needs.init.outputs.finish_slack_title }}' compact: '${{ needs.init.outputs.finish_slack_compact }}' debug: ${{ inputs.debug }}