Skip to content

Commit

Permalink
Merge pull request #96 from New-Barams/feat/#95/auto-merge
Browse files Browse the repository at this point in the history
[혜수] - Github Actions dev -> main 머지 자동화
  • Loading branch information
suehdn authored Nov 21, 2023
2 parents 7070f87 + edda33d commit c7bdfec
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .github/actions/slack-notify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: 'slack-notify'

inputs:
status:
required: false
default: 'failure'
slack_incoming_url:
required: true

runs:
using: 'composite'

steps:
- name: Send slack
shell: bash
run: |
if [ "${{ inputs.status }}" = "success" ]; then
EMOTICON="✅"
else
EMOTICON="⛔"
fi
MSG="{ \"username\": \"mergebot\",\"text\":\">${EMOTICON} workflow (<https://github.com/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}|${GITHUB_WORKFLOW}>) in <https://github.com/${GITHUB_REPOSITORY}|${GITHUB_REPOSITORY}>\n><https://github.com/${GITHUB_REPOSITORY}/commit/${GITHUB_SHA}/checks|${GITHUB_JOB}> job ${{ inputs.status }}, branch=\`${GITHUB_REF#refs/heads/}\`\", \"icon_emoji\": \":ghost:\"}"
curl -X POST -H 'Content-type: application/json' --data "${MSG}" "${{ inputs.slack_incoming_url }}"
32 changes: 32 additions & 0 deletions .github/workflows/merge-to-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Merge to Main

on:
schedule:
- cron: '0 0 * * 1,3' # 매주 월요일(1)과 수요일(3) 9:00 시에 실행되도록 스케줄 설정 (Cron 표현식)

jobs:
merge-to-main:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Merge to Main
run: |
git checkout main
git merge dev --no-ff --no-edit
git push origin main
- name: Send slack when failed
if: ${{ failure() }}
uses: ./.github/actions/slack-notify
with:
slack_incoming_url: ${{ secrets.SLACK_INCOMING_URL }}

- name: Send slack if completed
if: ${{ success() }}
uses: ./.github/actions/slack-notify
with:
status: success
slack_incoming_url: ${{ secrets.SLACK_INCOMING_URL }}

0 comments on commit c7bdfec

Please sign in to comment.