github actionsでwebhookurlを用いてslack通知しようとすると発生する403エラーを解決したい。
もともとpushやmergeをトリガーにgit errorを検知することでslack通知を送るプログラムを考えていたため以下のようなコードの構成にしました。
name: Slack Notification
on:
push:
branches:
- '*'
jobs:
slack_notification:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Detect Merge Conflict
id: conflict_check
run: |
git fetch origin develop
git merge-base --is-ancestor HEAD origin/develop
CONFLICT=$?
echo "::set-output name=conflict::$CONFLICT"
- name: Send Slack notification
uses: rtCamp/[email protected]
env:
SLACK_CHANNEL: "test"
SLACK_MESSAGE: "Pushed to branch by ${{ github.actor }}. Merge conflict: ${{ steps.conflict_check.outputs.conflict }}"
SLACK_WEBHOOK: ${{ var.WEBHOOKURL }}
発生したエラーは以下のようになります。
1.merge conflictを意図的に発生させたもの(本当はここでエラー検知した時もslack通知したい)
Run # Fetch the current develop branch
# Fetch the current develop branch
git fetch origin develop
# Check if the current commit is ancestor of the master branch
git merge-base --is-ancestor HEAD origin/develop
CONFLICT=$?
# Save the exit code (merge conflict information) to the output of this step
echo "::set-output name=conflict::$CONFLICT"
shell: /usr/bin/bash -e {0}
From https://github.com/Spacee-Inc/deploy
* branch develop -> FETCH_HEAD
* [new branch] develop -> origin/develop
Error: Process completed with exit code 1.
2.処理が正常終了してもslack通知がいかなくて非推奨警告が来る。
slack_notification
The `set-output` command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/