ãã«ãææç©ããªãã¸ããªã«å«ããå¿ è¦ãããå ´åãã©ã®ã¿ã¤ãã³ã°ã§ã³ãããããããåé¡ã«ãªãã¾ãã ä¾ãã°GitHub Actionsã®ããã«ãJavaScriptã®ææç©ããªãã¸ããªã«å«ããå¿ è¦ããããããªã±ã¼ã¹ã§ãã ãªãªã¼ã¹ãæã¤æã«ãã«ãææç©ãã³ãããããã¨ããæ¹æ³ãããã¾ããããã®è¨äºã§ã¯ã¡ã¤ã³ãã©ã³ãã¸ã®ãã¼ã¸æã«ã¯ãã«ãããªãã¨ãããªãã¨ããåæããããã¨ã«ãã¾ãã
人éãPRãåºãå ´åã¯æå ãããã«ããã¦ææç©ãä¸ç·ã«ã³ãããã§ãã¾ãããdependabotã®ãããªbotã«ã¯ãã«ããããããã¨ãã§ãã¾ããã ããããGitHub Actionsã使ãã°ãdependabotã®PRã«å¯¾ãã¦ããã«ãææç©ãã³ããããããã¨ãã§ãã¾ãã
name: CI on: push: branches: - main pull_request: jobs: test: name: Test runs-on: ubuntu-latest permissions: contents: read steps: - name: Checkout code uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.sha || github.sha }} token: ${{ secrets.DEPENDABOT_TOKEN || secrets.GITHUB_TOKEN }} fetch-depth: ${{ github.actor == 'dependabot[bot]' && 2 || 1 }} - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: 20 cache: npm - name: Install Dependencies run: npm ci - name: Run tests run: npm run test - name: Build run: npm run build - name: Check for dist changes id: dist-changes run: git diff --exit-code - name: Push dist changes for dependabot if: github.actor == 'dependabot[bot]' && failure() && steps.dist-changes.outcome == 'failure' run: | git config user.name "$(git show -s --format=%an)" git config user.email "$(git show -s --format=%ae)" git commit --all --amend --no-edit git push --force origin "HEAD:${GITHUB_HEAD_REF}"
GITHUB_TOKEN
ã®æ¨©éãå¼·ããããªãã®ã§ãpermissions
ã¯èªã¿åã権éã®ã¿ã«ãã¦ãã¾ããDependabot secretã使ããã¨ã§ãdependabotã®PRã§ããå©ç¨ã§ããªãã·ã¼ã¯ã¬ãããè¨å®ã§ãã¾ãããã®ã·ã¼ã¯ã¬ããã«ã¯è©²å½ãªãã¸ããªã¸ã®write権éãä»ä¸ããã¢ã¯ã»ã¹ãã¼ã¯ã³ãè¨å®ãã¦ããã¾ããpull_request
ã¤ãã³ãã§actions/checkout
ã使ãã¨ããã¼ã¸ã³ãããããã§ãã¯ã¢ã¦ããã¦ãã¾ãã¾ããä»åã¯PRã«ã³ããããç©ã¿ããã®ã§ãref
ã«github.event.pull_request.head.sha
ã¨push
ã¤ãã³ãæã®ãã©ã¼ã«ããã¯ãæå®ãã¾ãã- ãã¨ã¯ãã¹ãã¨ãã«ããè¡ãã¾ããããã¦ãã«ãææç©ãå¤æ´ããã¦ãããã確èªããããå¤æ´ãããã°dependabotã®PRã«ã³ããããã¾ããä»åã¯ããã±ã¼ã¸ã®æ´æ°ã³ãããã«amendãããã£ãã®ã§ã
push --force
ã§æ´æ°ãã¦ãã¾ããã¾ããfetch-depth
ã2ã«ãã¦ãã¾ããããamendããªãå ´åã¯push --force
ãä¸è¦ã§fetch-depth
ãæå®ããªãã§ãåé¡ããã¾ããã
ãã¤ã³ãã¯ãã§ãã¯ã¢ã¦ãããã¨ãã®ref
ã¨ãDependabot secretã使ããã¨ã§ããããã
GitHub Actionsããããªã®ã§ããããã«ãææç©ãã³ãããããªããã°ãªããªãã¨ããã·ãã¥ã¨ã¼ã·ã§ã³ã¯ããããçããããããã¾ããã
ããããDependabot secretã®åå¨ãç¥ã£ã¦ããã¨ãdependabotã®PRã«ã®ã¿å©ç¨ã§ããã·ã¼ã¯ã¬ãããè¨å®ã§ããã®ã§ã¨ã¦ã便å©ã§ããã
ããã§ã¯ã¾ãï¼