Daily Instagram Post #19
This file contains hidden or 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
| name: Daily Instagram Post | |
| on: | |
| schedule: | |
| # 매일 오후 6시 (KST) = UTC 9시 | |
| - cron: '0 9 * * *' | |
| workflow_dispatch: # 수동 실행 | |
| inputs: | |
| date: | |
| description: '포스팅 날짜 (YYYY-MM-DD, 비워두면 오늘)' | |
| required: false | |
| default: '' | |
| post_type: | |
| description: '포스팅 타입' | |
| required: true | |
| default: 'both' | |
| type: choice | |
| options: | |
| - both | |
| - abandoned | |
| - lost | |
| jobs: | |
| post: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install Chrome | |
| uses: browser-actions/setup-chrome@latest | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install requests pillow selenium webdriver-manager python-dotenv | |
| - name: Get date | |
| id: date | |
| run: | | |
| if [ -n "${{ github.event.inputs.date }}" ]; then | |
| echo "target_date=${{ github.event.inputs.date }}" >> $GITHUB_OUTPUT | |
| else | |
| echo "target_date=$(TZ=Asia/Seoul date +'%Y-%m-%d')" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Post abandoned animals | |
| if: github.event_name == 'schedule' || github.event.inputs.post_type != 'lost' | |
| env: | |
| INSTAGRAM_ACCESS_TOKEN: ${{ secrets.INSTAGRAM_ACCESS_TOKEN }} | |
| INSTAGRAM_ACCOUNT_ID: ${{ secrets.INSTAGRAM_ACCOUNT_ID }} | |
| ANIMAL_API_KEY: ${{ secrets.ANIMAL_API_KEY }} | |
| FINDYOU_CDN_URL: ${{ secrets.FINDYOU_CDN_URL }} | |
| FINDYOU_CDN_TOKEN: ${{ secrets.FINDYOU_CDN_TOKEN }} | |
| run: | | |
| cd abandoned_animals/instagram | |
| python run_post.py ${{ steps.date.outputs.target_date }} --post | |
| - name: Post lost animals | |
| if: github.event_name == 'schedule' || github.event.inputs.post_type != 'abandoned' | |
| env: | |
| INSTAGRAM_ACCESS_TOKEN: ${{ secrets.INSTAGRAM_ACCESS_TOKEN }} | |
| INSTAGRAM_ACCOUNT_ID: ${{ secrets.INSTAGRAM_ACCOUNT_ID }} | |
| ANIMAL_API_KEY: ${{ secrets.ANIMAL_API_KEY }} | |
| FINDYOU_CDN_URL: ${{ secrets.FINDYOU_CDN_URL }} | |
| FINDYOU_CDN_TOKEN: ${{ secrets.FINDYOU_CDN_TOKEN }} | |
| run: | | |
| cd abandoned_animals/instagram | |
| python run_post_lost.py ${{ steps.date.outputs.target_date }} --post | |
| - name: Commit posted animals record | |
| run: | | |
| git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
| git config --local user.name "github-actions[bot]" | |
| git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git | |
| if [ -f "abandoned_animals/instagram/data/posted_lost_animals.json" ]; then | |
| git add abandoned_animals/instagram/data/posted_lost_animals.json | |
| if ! git diff --staged --quiet; then | |
| git commit -m "🤖 Update posted lost animals record $(TZ=Asia/Seoul date +'%Y-%m-%d')" | |
| git push origin main | |
| fi | |
| fi |