Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[24.12.22 / TASK-67] Feature - 메인 배치 기본 깃액션 추가 #9

Merged
merged 2 commits into from
Dec 22, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 105 additions & 0 deletions .github/workflows/run-daily-aggre.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
name: Velog Dashboard Scraping

on:
workflow_dispatch:
# schedule:
# 30분 마다 동작
# - cron: "*/30 * * * *"

Nuung marked this conversation as resolved.
Show resolved Hide resolved
jobs:
scrape-velog-posts:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Python
uses: actions/setup-python@v4
with:
python-version: 3.13.0

Nuung marked this conversation as resolved.
Show resolved Hide resolved
- name: Install Poetry
uses: abatilo/actions-poetry@v2
with:
poetry-version: 1.8.4

- name: Setup a local virtual environment
run: |
poetry config virtualenvs.create true --local
poetry config virtualenvs.in-project true --local

- name: Define a cache for the virtual environment
uses: actions/cache@v3
with:
path: ./.venv
key: venv-${{ hashFiles('poetry.lock') }}-${{ runner.os }}

Nuung marked this conversation as resolved.
Show resolved Hide resolved
- name: Install dependencies
run: poetry install --with dev

- name: Create .env file
run: |
echo "SECRET_KEY=${{ secrets.SECRET_KEY }}" >> .env
echo "DEBUG=False" >> .env
echo "DATABASE_ENGINE=${{ secrets.DATABASE_ENGINE }}" >> .env
echo "DATABASE_NAME=${{ secrets.DATABASE_NAME }}" >> .env
echo "POSTGRES_USER=${{ secrets.POSTGRES_USER }}" >> .env
echo "POSTGRES_PASSWORD=${{ secrets.POSTGRES_PASSWORD }}" >> .env
echo "POSTGRES_HOST=${{ secrets.POSTGRES_HOST }}" >> .env
echo "POSTGRES_PORT=${{ secrets.POSTGRES_PORT }}" >> .env
echo "AES_KEY_0=${{ secrets.AES_KEY_0 }}" >> .env
echo "AES_KEY_1=${{ secrets.AES_KEY_1 }}" >> .env
echo "AES_KEY_2=${{ secrets.AES_KEY_2 }}" >> .env
echo "AES_KEY_3=${{ secrets.AES_KEY_3 }}" >> .env
echo "AES_KEY_4=${{ secrets.AES_KEY_4 }}" >> .env
echo "AES_KEY_5=${{ secrets.AES_KEY_5 }}" >> .env
echo "AES_KEY_6=${{ secrets.AES_KEY_6 }}" >> .env
echo "AES_KEY_7=${{ secrets.AES_KEY_7 }}" >> .env
echo "AES_KEY_8=${{ secrets.AES_KEY_8 }}" >> .env
echo "AES_KEY_9=${{ secrets.AES_KEY_9 }}" >> .env

- name: Run Velog Scraping Script
id: velog-daily-stats-main
run: |
poetry run python scraping/main.py

Nuung marked this conversation as resolved.
Show resolved Hide resolved
- name: Send Slack Notification on Success
if: success()
uses: slackapi/[email protected]
with:
payload: |
{
"text": "✅ Velog Dashboard Daily Stats Batch Successful",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Velog Dashboard Daily Stats Batch*\n\n✅ *Status:* Success\n📅 *Timestamp:* <!date^${{ github.event.repository.updated_at }}^{date_short_pretty} {time}|Timestamp>\n🔗 *Workflow URL:* ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
}
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

- name: Send Slack Notification on Failure
if: failure()
uses: slackapi/[email protected]
with:
payload: |
{
"text": "❌ Velog Dashboard Daily Stats Batch Failed",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Velog Dashboard Daily Stats Batch*\n\n❌ *Status:* Failure\n📅 *Timestamp:* <!date^${{ github.event.repository.updated_at }}^{date_short_pretty} {time}|Timestamp>\n🔗 *Workflow URL:* ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
}
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
Loading