Scheduled Workflow #654
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: Scheduled Workflow | |
on: | |
schedule: | |
- cron: '0 0 * * *' | |
jobs: | |
tests: | |
name: Tests | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18.x' | |
cache: 'yarn' | |
- name: Install Deps & Run Tests | |
run: yarn install --frozen-lockfile && yarn test:ci | |
update_list: | |
name: Modify TokenList | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.head_ref }} | |
- name: Setup Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18.x' | |
cache: 'yarn' | |
- name: Run Script | |
run: | | |
yarn install --frozen-lockfile | |
chmod +x ./run.sh | |
./run.sh | |
shell: bash | |
- name: Commit Update | |
run: | | |
git config user.name github-actions | |
git config user.email [email protected] | |
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} | |
if [ -n "$(git status --porcelain)" ]; then | |
git pull | |
git checkout -f "Automated-TokenList-Update" | |
./run.sh | |
git add . | |
git commit -m "Updated TokenList" ||echo "Branch is up to date" | |
git push -u origin "Automated-TokenList-Update" | |
gh pr create -B main -H Automated-TokenList-Update --title 'TokenList Updated' --body 'PR created by Github Actions. Review PR and add changeset to release' || echo "PR already exists" | |
else | |
echo "Repo is clean" | |
fi | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
release: | |
if: ${{ github.ref == 'refs/heads/main' }} | |
runs-on: ubuntu-latest | |
needs: tests | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Use Node.js 18.x | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18.x | |
- name: Creating .npmrc | |
run: | | |
cat << EOF > "$HOME/.npmrc" | |
//registry.npmjs.org/:_authToken=$NPM_TOKEN | |
EOF | |
env: | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Install Dependencies | |
run: yarn install --frozen-lockfile | |
- name: Create Release Pull Request or Publish to npm | |
uses: changesets/action@v1 | |
with: | |
publish: yarn release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |