Daily tweet #462
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
name: Daily tweet | |
on: | |
push: | |
branches: | |
- main | |
schedule: | |
- cron: "30 8 * * *" | |
- cron: "30 12 * * *" | |
- cron: "30 17 * * *" | |
workflow_dispatch: | |
permissions: | |
contents: write | |
jobs: | |
tweet: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20.x' | |
- name: Cache node modules | |
uses: actions/cache@v3 | |
env: | |
cache-name: cache-node-modules | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}- | |
${{ runner.os }}-build- | |
${{ runner.os }}- | |
- name: Cache Puppeteer | |
uses: actions/cache@v3 | |
with: | |
path: ~/.cache/puppeteer | |
key: ${{ runner.os }}-puppeteer-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-puppeteer- | |
- name: Install dependencies | |
run: | | |
npm ci | |
npm install puppeteer | |
- name: Install additional dependencies for Puppeteer | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y libgbm-dev libnss3 libatk-bridge2.0-0 libdrm2 libxkbcommon0 libgbm1 libasound2-dev libatspi2.0-0 libxshmfence1 | |
- name: Load secrets from 1Password | |
uses: 1password/load-secrets-action@v2 | |
with: | |
export-env: true | |
env: | |
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }} | |
TWITTER_APP_KEY: op://abeona/cowsay-bot/TWITTER_APP_KEY | |
TWITTER_APP_SECRET: op://abeona/cowsay-bot/TWITTER_APP_SECRET | |
TWITTER_ACCESS_TOKEN: op://abeona/cowsay-bot/TWITTER_ACCESS_TOKEN | |
TWITTER_ACCESS_SECRET: op://abeona/cowsay-bot/TWITTER_ACCESS_SECRET | |
- name: Generate and post tweet | |
run: npm run start | |
env: | |
TWITTER_APP_KEY: ${{ env.TWITTER_APP_KEY }} | |
TWITTER_APP_SECRET: ${{ env.TWITTER_APP_SECRET }} | |
TWITTER_ACCESS_TOKEN: ${{ env.TWITTER_ACCESS_TOKEN }} | |
TWITTER_ACCESS_SECRET: ${{ env.TWITTER_ACCESS_SECRET }} | |
- name: Commit and push used quotes | |
run: | | |
git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
git add src/used_quotes.json | |
git commit -m "Update used quotes" || echo "No changes to commit" | |
git push | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |