Skip to content

Commit

Permalink
improve GitHub Action build times (#742)
Browse files Browse the repository at this point in the history
  • Loading branch information
jetersen committed Dec 27, 2020
1 parent ddcbf38 commit 329e805
Show file tree
Hide file tree
Showing 24 changed files with 129,457 additions and 79 deletions.
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ node_modules
coverage
.buildkite
*.pem
.git
.git
dist/
4 changes: 3 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
coverage
coverage
dist/
node_modules/
7 changes: 7 additions & 0 deletions .github/no-unstaged-files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

if [[ "$(git status --porcelain)" != "" ]]; then
git status
echo "::error::💥 Unstaged changes detected. Locally try running: yarn prettier && yarn lint --fix && yarn build"
exit 1
fi
18 changes: 0 additions & 18 deletions .github/workflows/lint.yml

This file was deleted.

9 changes: 5 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: '13'
- name: Test
run: |
yarn install
yarn test
- run: yarn install --frozen-lockfile
- run: yarn test
- run: yarn lint --fix
- run: yarn prettier
- run: .github/no-unstaged-files.sh
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ coverage
now.json
docker-compose-logs
package-lock.json
dist/static/
dist/views/
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
config-with-yaml-exception.yml
dist/
coverage/
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"eslint.autoFixOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"files.exclude": {
"dist/": true
}
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ You can use any of the following variables in your `template`, `name-template` a
| `$NEXT_PATCH_VERSION` | The next patch version number. For example, if the last tag or release was `v1.2.3`, the value would be `v1.2.4`. This is the most commonly used value. |
| `$NEXT_MINOR_VERSION` | The next minor version number. For example, if the last tag or release was `v1.2.3`, the value would be `v1.3.0`. |
| `$NEXT_MAJOR_VERSION` | The next major version number. For example, if the last tag or release was `v1.2.3`, the value would be `v2.0.0`. |
| `$RESOLVED_VERSION` | The next resolved version number, based on GitHub labels. Refer to [Version Resolver](#version-resolver) to learn more about this. |
| `$RESOLVED_VERSION` | The next resolved version number, based on GitHub labels. Refer to [Version Resolver](#version-resolver) to learn more about this. |

## Version Template Variables

Expand Down
42 changes: 42 additions & 0 deletions action.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const { createProbot } = require('probot')
const core = require('@actions/core')
const app = require('./index')

run().catch((err) => {
core.setFailed(`💥 Release drafter failed with error: ${err.message}`)
})

async function run() {
if (!process.env.GITHUB_TOKEN) {
throw new Error(
'env.GITHUB_TOKEN must be set, see https://github.com/probot/example-github-action#usage'
)
}

const envVariablesMissing = [
'GITHUB_RUN_ID',
'GITHUB_EVENT_NAME',
'GITHUB_EVENT_PATH',
].filter((name) => !process.env[name])

if (envVariablesMissing.length) {
const missingEnvs = envVariablesMissing.join(', ')
throw new Error(
`GitHub Action default environment variables missing: ${missingEnvs}. See https://docs.github.com/en/free-pro-team@latest/actions/reference/environment-variables#default-environment-variables`
)
}

const probot = createProbot({
overrides: {
githubToken: process.env.GITHUB_TOKEN,
},
})

await probot.load(app)

return probot.receive({
id: process.env.GITHUB_RUN_ID,
name: process.env.GITHUB_EVENT_NAME,
payload: require(process.env.GITHUB_EVENT_PATH),
})
}
4 changes: 2 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: 'Release Drafter'
description: 'Drafts your next release notes as pull requests are merged into master.'
runs:
using: 'docker'
image: 'Dockerfile'
using: 'node12'
main: 'dist/index.js'
branding:
icon: edit-2
color: orange
Expand Down
Loading

0 comments on commit 329e805

Please sign in to comment.