update_appveyor_image.yml 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. name: Update AppVeyor Image
  2. # Run chron daily Mon-Fri
  3. on:
  4. workflow_dispatch:
  5. schedule:
  6. - cron: '0 8 * * 1-5' # runs 8:00 every business day (see https://crontab.guru)
  7. permissions: {}
  8. jobs:
  9. bake-appveyor-image:
  10. name: Bake AppVeyor Image
  11. runs-on: ubuntu-latest
  12. steps:
  13. - name: Generate GitHub App token
  14. uses: electron/github-app-auth-action@384fd19694fe7b6dcc9a684746c6976ad78228ae # v1.1.1
  15. id: generate-token
  16. with:
  17. creds: ${{ secrets.APPVEYOR_UPDATER_GH_APP_CREDS }}
  18. - name: Checkout
  19. uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
  20. with:
  21. fetch-depth: 0
  22. token: ${{ steps.generate-token.outputs.token }}
  23. ref: ${{ github.event.pull_request.head.sha }}
  24. - name: Setup Node.js
  25. uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
  26. with:
  27. node-version: 20.11.x
  28. - name: Yarn install
  29. run: |
  30. node script/yarn.js install --frozen-lockfile
  31. - name: Set Repo for Commit
  32. run: git config --global --add safe.directory $GITHUB_WORKSPACE
  33. - name: Check AppVeyor Image
  34. env:
  35. APPVEYOR_TOKEN: ${{ secrets.APPVEYOR_TOKEN }}
  36. run: |
  37. node ./script/prepare-appveyor
  38. if [ -f ./image_version.txt ]; then
  39. echo "APPVEYOR_IMAGE_VERSION="$(cat image_version.txt)"" >> $GITHUB_ENV
  40. rm image_version.txt
  41. fi
  42. - name: (Optionally) Update Appveyor Image
  43. if: ${{ env.APPVEYOR_IMAGE_VERSION }}
  44. uses: mikefarah/yq@4839dbbf80445070a31c7a9c1055da527db2d5ee # v4.44.6
  45. with:
  46. cmd: |
  47. yq '.image = "${{ env.APPVEYOR_IMAGE_VERSION }}"' "appveyor.yml" > "appveyor2.yml"
  48. yq '.image = "${{ env.APPVEYOR_IMAGE_VERSION }}"' "appveyor-woa.yml" > "appveyor-woa2.yml"
  49. - name: (Optionally) Generate Commit Diff
  50. if: ${{ env.APPVEYOR_IMAGE_VERSION }}
  51. run: |
  52. diff -w -B appveyor.yml appveyor2.yml > appveyor.diff || true
  53. patch -f appveyor.yml < appveyor.diff
  54. rm appveyor2.yml appveyor.diff
  55. git add appveyor.yml
  56. - name: (Optionally) Generate Commit Diff for WOA
  57. if: ${{ env.APPVEYOR_IMAGE_VERSION }}
  58. run: |
  59. diff -w -B appveyor-woa.yml appveyor-woa2.yml > appveyor-woa.diff || true
  60. patch -f appveyor-woa.yml < appveyor-woa.diff
  61. rm appveyor-woa2.yml appveyor-woa.diff
  62. git add appveyor-woa.yml
  63. - name: (Optionally) Commit to Branch
  64. if: ${{ env.APPVEYOR_IMAGE_VERSION }}
  65. uses: dsanders11/github-app-commit-action@43de6da2f4d927e997c0784c7a0b61bd19ad6aac # v1.5.0
  66. with:
  67. message: 'build: update appveyor image to latest version'
  68. ref: bump-appveyor-image
  69. token: ${{ steps.generate-token.outputs.token }}
  70. - name: (Optionally) Create Pull Request
  71. if: ${{ env.APPVEYOR_IMAGE_VERSION }}
  72. run: |
  73. printf "This PR updates appveyor.yml to the latest baked image, ${{ env.APPVEYOR_IMAGE_VERSION }}.\n\nNotes: none" | gh pr create --head bump-appveyor-image --label no-backport --label semver/none --title 'build: update appveyor image to latest version' --body-file=-
  74. env:
  75. GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}