on:
pull_request:
branches:
- main
on:
push:
branches:
- main
pull_request:
branches:
- main
on:
workflow_run:
workflows: ["CI Pipeline"]
types:
- completed
jobs:
build:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
...
deploy:
needs: build
...
steps:
- name: Checkout PR branch
uses: actions/checkout@v4
with:
ref: ${{ github.event.workflow_run.head_branch }}
이번에 새로 TIL 스터디에 참가하게 되었고, discord에서 인증하게 되었다. 일요일마다 주간 목표를 공유하는 데, 이때 알람 기능이 있었으면 좋겠다고 생각하여 github 호스팅 러너로 discord-webhook을 사용하기로 결정했다.
테스트를 위해 1분마다 실행되게 했는데, github-action은 최소 실행 단위가 5분 단위라고 한다. 그래서 아래와 같이 스크립트를 작성해 주었다.
name: Send Discord Message
on:
schedule:
- cron: '*/5 * * * *'
workflow_dispatch:
jobs:
sendMessage:
runs-on: ubuntu-24.04
steps:
- name: Send Message to Discord Channel!
run: |
curl -X POST \
-H "Content-Type: application/json" \
-d "{\"content\": \"This is a scheduled message form Github Actions!\"}" \
${{ secrets.DISCORD_WEBHOOK_URL }}
on:
schedule:
- cron: '0 1 * * 0'