Auto Build All Dependencies and DevDependencies #51
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: Auto Build All Dependencies and DevDependencies | |
on: | |
schedule: | |
# ββββββββββββββ minute (0 - 59) | |
# β ββββββββββββββ hour (0 - 23) | |
# β β ββββββββββββββ day of the month (1 - 31) | |
# β β β ββββββββββββββ month (1 - 12 or JAN-DEC) | |
# β β β β ββββββββββββββ day of the week (0 - 6 or SUN-SAT) | |
# β β β β β | |
# β β β β β | |
# β β β β β | |
# * * * * * | |
- cron: "0 0 */7 * *" | |
workflow_dispatch: | |
permissions: | |
actions: read | |
checks: read | |
contents: write | |
deployments: read | |
issues: read | |
discussions: read | |
packages: read | |
pages: read | |
pull-requests: write | |
repository-projects: read | |
security-events: read | |
statuses: read | |
jobs: | |
autoBuildDeps: | |
runs-on: ubuntu-latest | |
name: Auto build deps | |
strategy: | |
matrix: | |
node-version: [22.x] | |
steps: | |
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | |
- name: Setup Node | |
uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: npm | |
# Fix the unsafe repo error which was introduced by the CVE-2022-24765 git patches. | |
- name: Fix unsafe repo error | |
run: git config --global --add safe.directory ${{ github.workspace }} | |
- name: Update git repository | |
run: git pull | |
- name: Run npm install and update | |
run: | | |
npm ci | |
npm update --save | |
npm audit fix | |
env: | |
CI: true | |
- name: Set up Git | |
run: | | |
git config user.name "github-actions[bot]" | |
git config user.email "github-actions[bot]@users.noreply.github.com" | |
git config --global --add safe.directory ${GITHUB_WORKSPACE} | |
- name: Push commit to a new branch | |
run: | | |
branch="auto_build_and_bump" | |
message="build(deps): bump all dependencies and devDependencies version" | |
body="_This pull request was created automatically._" | |
if [[ "$(git status --porcelain)" != "" ]]; then | |
git branch -D ${branch} || true | |
git checkout -b ${branch} | |
git add package.json package-lock.json | |
git commit --message "${message}" | |
git remote add origin-${branch} "https://github.com/FajarKim/github-readme-profile.git" | |
git push --force --quiet --set-upstream origin-${branch} ${branch} | |
gh pr create --title "${message}" --body "${body}" | |
fi | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |