-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d8ac900
commit 0a90432
Showing
4 changed files
with
72 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: unsubscribe | ||
on: | ||
issues: | ||
types: [closed] | ||
permissions: | ||
issues: write | ||
jobs: | ||
unsubscribe: | ||
if: contains(github.event.issue.labels.*.name, '구독신청') | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install jq | ||
run: sudo apt-get install jq | ||
|
||
- name: Set execute permission for script | ||
run: chmod +x ./scripts/unsubscribe.sh | ||
|
||
- name: unsubscribe | ||
continue-on-error: false | ||
run: | | ||
./scripts/unsubscribe.sh "${{ github.event.issue.body}}" "${{ secrets.API_GATEWAY_URL }}" | ||
- name: Add comment | ||
run: gh issue comment "$NUMBER" --body "$BODY" | ||
env: | ||
NUMBER: ${{ github.event.issue.number }} | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
GH_REPO: ${{ github.repository }} | ||
BODY: | | ||
구독이 취소되었습니다. | ||
**다시 이메일 알림을 받고 싶다면?** | ||
> Close된 Issue를 다시 Open 해주세요. 자동화된 프로세스로 구독을 신청합니다. |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
INPUT_TEXT="$1" | ||
API_URL="$2" | ||
|
||
# 이메일 주소 추출 | ||
EMAIL=$(echo "$INPUT_TEXT" | grep -oP '[\w.+-]+@[\w-]+\.[\w.-]+') | ||
|
||
if [ -z "$EMAIL" ]; then | ||
echo "Error: 입력 텍스트에서 이메일 주소를 찾을 수 없습니다." | ||
exit 1 | ||
fi | ||
|
||
JSON_DATA=$(jq -n \ | ||
--arg email "$EMAIL" \ | ||
'{email: $email}') | ||
|
||
FULL_URL="${API_URL}/unsubscribe" | ||
|
||
# Post 요청 | ||
RESPONSE=$(curl -s -w "\n%{http_code}" -X POST -H "Content-Type: application/json" -d "$JSON_DATA" "$FULL_URL") | ||
|
||
# 응답 본문과 상태 코드 분리 | ||
HTTP_BODY=$(echo "$RESPONSE" | sed '$d') | ||
HTTP_STATUS=$(echo "$RESPONSE" | tail -n1) | ||
|
||
# 상태 코드에 따른 처리 | ||
if [ "$HTTP_STATUS" == "204" ]; then | ||
echo "Success: 구독 취소가 성공적으로 완료되었습니다." | ||
echo "응답 본문: $HTTP_BODY" | ||
exit 0 | ||
else | ||
echo "Error: 구독 취소 요청이 실패했습니다. HTTP 상태 코드: $HTTP_STATUS" | ||
echo "응답 본문: $HTTP_BODY" | ||
exit 1 | ||
fi |