Lock file maintenance #468
Workflow file for this run
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
on: | |
schedule: | |
# Every Sunday 23:00 | |
- cron: '0 23 * * 0' | |
pull_request: | |
types: [labeled, unlabeled] | |
issue_comment: | |
types: [edited] | |
workflow_dispatch: | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
TWIOS_BRANCH: ${{ github.event.pull_request.head.ref || 'master' }} | |
TWIOS_PR_REF: ${{ github.event.pull_request.head.ref }} | |
permissions: | |
pull-requests: write | |
contents: write | |
jobs: | |
create_twios: | |
runs-on: ubuntu-latest | |
if: ${{!github.event.pull_request.body && github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || github.event.label.name == 'create-twios'}} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
registry-url: "https://registry.npmjs.org" | |
- uses: pnpm/action-setup@v2 | |
name: Install pnpm | |
with: | |
version: 8 | |
- name: Fetch $TWIOS_BRANCH | |
run: | | |
git fetch origin $TWIOS_BRANCH | |
git checkout $TWIOS_BRANCH | |
- name: Configure local git | |
run: | | |
git config --global user.email "twios@twios_test_dev.com" | |
git config --global user.name "TWIOS Dev" | |
- name: Generate Comment | |
run: | | |
GITHUB_PERSONAL_TOKEN=$GITHUB_TOKEN twios/this-week-in-open-source --config-path=config/this-week-in-open-source.config.json comment > comment.txt | |
- run: pnpm install | |
- name: Generate TWIOS | |
run: GITHUB_PERSONAL_TOKEN=$GITHUB_TOKEN twios/this-week-in-open-source --config-path=config/this-week-in-open-source.config.json | |
- run: pnpm lint:fix | |
- name: Push new TWIOS | |
run: | | |
FORMATTED_DATE="$(date +"%Y-%m-%d")" | |
BRANCH_NAME="twios-$FORMATTED_DATE" | |
git checkout -b $BRANCH_NAME | |
git add **/*.md **/*.json && git commit -m "$BRANCH_NAME" | |
git push --set-upstream origin $BRANCH_NAME | |
gh pr create -a IdeliaRisella --base $TWIOS_BRANCH --head $BRANCH_NAME --title "TWIOS $FORMATTED_DATE" --body-file comment.txt | |
edit_twios: | |
runs-on: ubuntu-latest | |
if: ${{github.event.pull_request.body && contains(github.event.pull_request.head.ref, 'twios') || github.event.label.name == 'edit-twios'}} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
registry-url: "https://registry.npmjs.org" | |
- uses: pnpm/action-setup@v2 | |
name: Install pnpm | |
with: | |
version: 8 | |
- name: Fetch $TWIOS_PR_REF | |
run: | | |
git fetch origin $TWIOS_PR_REF | |
git checkout $TWIOS_PR_REF | |
- name: Configure local git | |
run: | | |
git config --global user.email "twios@twios_test_dev.com" | |
git config --global user.name "TWIOS Dev" | |
- name: Read PR comment body | |
run: | | |
GITHUB_PERSONAL_TOKEN=$GITHUB_TOKEN twios/this-week-in-open-source --config-path=config/this-week-in-open-source.config.json comment --comment="${{ github.event.pull_request.body }}" | |
- run: pnpm install | |
- name: Generate TWIOS | |
run: GITHUB_PERSONAL_TOKEN=$GITHUB_TOKEN twios/this-week-in-open-source --config-path=config/this-week-in-open-source.config.json -edit | |
- run: pnpm lint:fix | |
- name: Push updated TWIOS | |
run: | | |
git add **/*.md **/*.json && git commit -m "Edited $TWIOS_PR_REF" | |
git push |