|
4 | 4 | schedule: |
5 | 5 | # 毎朝 9:00 JST |
6 | 6 | - cron: '0 0 * * *' |
| 7 | + # Allows you to run this workflow manually from the Actions tab |
| 8 | + # https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow |
7 | 9 | workflow_dispatch: |
8 | 10 |
|
9 | 11 | jobs: |
10 | | - fetch: |
| 12 | + daily: |
11 | 13 | runs-on: ubuntu-latest |
12 | 14 |
|
13 | 15 | steps: |
14 | | - - name: Checkout repository |
15 | | - uses: actions/checkout@v4 |
| 16 | + - name: ☑️ Checkout code |
| 17 | + uses: actions/checkout@v4 |
| 18 | + with: |
| 19 | + fetch-depth: 2 |
16 | 20 |
|
17 | | - - name: Set up Ruby |
18 | | - uses: ruby/setup-ruby@v1 |
| 21 | + - name: 💎 Setup Ruby |
| 22 | + uses: ruby/setup-ruby@v1 |
| 23 | + with: |
| 24 | + bundler-cache: true |
| 25 | + |
| 26 | + - name: 🧪 Install dependencies |
| 27 | + run: bundle install |
| 28 | + |
| 29 | + - name: 📰 Run news:fetch task |
| 30 | + run: bin/rails news:fetch |
| 31 | + |
| 32 | + - name: 🆙 Commit updated news.yml |
| 33 | + run: | |
| 34 | + git config user.name "Yohei Yasukawa" |
| 35 | + git config user.email "yohei@yasslab.jp" |
| 36 | + git checkout main |
| 37 | + git add db/news.yml |
| 38 | + if ! git diff --cached --quiet; then |
| 39 | + git commit -m '🤖 Upsert db/news.yml' |
| 40 | + git push origin main |
| 41 | + echo "🆕 Found news in db/news.yml" |
| 42 | + echo "FOUND_NEWS=true" >> $GITHUB_ENV |
| 43 | + else |
| 44 | + echo "✅ No news in db/news.yml" |
| 45 | + echo "FOUND_NEWS=false" >> $GITHUB_ENV |
| 46 | + fi |
| 47 | +
|
| 48 | + - name: ✅ Do nothing if no news found |
| 49 | + if: ${{ env.FOUND_NEWS == 'false' }} |
| 50 | + run: | |
| 51 | + echo "No news found." |
| 52 | +
|
| 53 | + - name: 🚀 Deploy to Heroku if news found |
| 54 | + if: ${{ env.FOUND_NEWS == 'true' }} |
| 55 | + # TODO: This workflows depend on Ubuntu version. |
| 56 | + # https://github.com/AkhileshNS/heroku-deploy/issues/186 |
| 57 | + runs-on: ubuntu-22.04 |
| 58 | + steps: |
| 59 | + - uses: actions/checkout@v3 |
| 60 | + - uses: akhileshns/heroku-deploy@v3.13.15 |
19 | 61 | with: |
20 | | - bundler-cache: true |
21 | | - |
22 | | - - name: Install dependencies |
23 | | - run: bundle install |
24 | | - |
25 | | - - name: Run news:fetch task |
26 | | - run: bin/rails news:fetch |
27 | | - |
28 | | - - name: Commit updated news.yml |
29 | | - run: | |
30 | | - git config user.name "github-actions[bot]" |
31 | | - git config user.email "github-actions[bot]@users.noreply.github.com" |
32 | | - git add db/news.yml |
33 | | - if ! git diff --cached --quiet; then |
34 | | - git commit -m "chore: update news.yml via GitHub Actions" |
35 | | - git push |
36 | | - else |
37 | | - echo "No changes in db/news.yml" |
38 | | - fi |
| 62 | + heroku_api_key: ${{ secrets.HEROKU_API_KEY }} |
| 63 | + heroku_app_name: ${{ secrets.HEROKU_APP_NAME }} |
| 64 | + heroku_email: ${{ secrets.HEROKU_EMAIL }} |
0 commit comments