Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup Weekly Automation to Update @actions/github #498

Merged
merged 13 commits into from
Jun 19, 2020
46 changes: 46 additions & 0 deletions .github/workflows/update-github.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: "UpdateOctokit"

on:
schedule:
- cron: '0 18 * * 0' # sunday at 18 UTC

jobs:
UpdateOctokit:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will forks inherit this cron workflow? Should we add a job-condition so it doesnt run on forks?

runs-on: ubuntu-latest
if: ${{ github.repository_owner == 'actions' }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Update Octokit
working-directory: packages/github
run: |
npx npm-check-updates -u --dep prod
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • consider --upgrade instead of -u (long form for readability in scripts, short form for interactive terminal)
  • is it fragile to assume npm-check-updates is installed globally?
  • curious whether considered running npm update commands instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Great Idea, I'll update it
  • npx will install items if they don't exist in path
  • Update respect semver, which is nice, but npm-check-updates will create a new pr will notify for new major versions. Even if the PR isn't perfect (the new version isn't compatible), the pr will act as a notification that we need to do something!

npm install
- name: Check Status
id: status
working-directory: packages/github
run: |
if [[ "$(git status --porcelain)" != "" ]]; then
echo "::set-output name=createPR::true"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
git checkout -b bots/updateGitHubDependencies-${{github.run_number}}
git add .
git commit -m "Update Dependencies"
git push --set-upstream origin bots/updateGitHubDependencies-${{github.run_number}}
fi
- name: Create PR
if: ${{steps.status.outputs.createPR}}
uses: actions/github-script@v2
with:
github-token: ${{secrets.GITHUB_TOKEN}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fyi, it looks like you could omit github-token: ... since ${{ github.token }} is the default

script: |
github.pulls.create(
{
base: "master",
owner: "${{github.repository_owner}}",
repo: "toolkit",
title: "Update Octokit dependencies",
body: "Update Octokit dependencies",
head: "bots/updateGitHubDependencies-${{github.run_number}}"
})
102 changes: 41 additions & 61 deletions packages/github/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions packages/github/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@
"url": "https://github.com/actions/toolkit/issues"
},
"dependencies": {
"@actions/http-client": "^1.0.3",
"@octokit/core": "^2.5.1",
"@octokit/plugin-paginate-rest": "^2.2.0",
"@octokit/plugin-rest-endpoint-methods": "^3.10.0"
"@actions/http-client": "^1.0.8",
"@octokit/core": "^3.0.0",
"@octokit/plugin-paginate-rest": "^2.2.3",
"@octokit/plugin-rest-endpoint-methods": "^4.0.0"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lots of changes to actions api here, going to release a new major version:
https://github.com/octokit/plugin-rest-endpoint-methods.js/releases/tag/v4.0.0

},
"devDependencies": {
"jest": "^25.1.0",
Expand Down