Read DESIGN.md for more information about goals of this
project and how things are organised and why.
-
Copy
workflow-templates/*.yamlfiles from verkstedt/.github (not this repository) to.github/workflows/in your repository.- skip
chromatic, if your project doesn’t use it - skip
jira, if your project doesn’t use it
- skip
-
If your project doesn’t have
package.jsonin the root, changeworking-directoryfrom.in all of the files that define it.If you have multiple
package.jsonfiles, create separate YAML files for each of them. Also changename:to be able to distinguish between them. -
You might have these defined on the GitHub organisation level, but want to overwrite them with project–specific values:
-
SLACK_CHANNEL_IDvar, if you have a project–specific channel- In Slack, open the channel.
- Open the channel details (the channel name on the top of the screen)
- The channel ID is at the bottom
-
JIRA_STATUS_*vars, if your project uses custom status names. You can also set var to empty string to disable that transition.
-
-
Create a test PR to check if workflows run as expected.
Some of the checks are skipped for draft PRs, so make sure to publish.
-
When workflows run, they will most probably fail, because some secrets and/or vars are missing, but error messages should guide you where to take them from.
-
If “CI” workflow didn’t detect something you’d want it to run, customise it (see comments in the file).
-
Set your
mainbranch as protected and require passing the checks. 🔓Make all of the “CI / CI / (…)” checks that were not skipped in your test PR required. If you use Chromatic, you’ll also want to make “UI Tests” required.
-
Template: https://github.com/verkstedt/.github/tree/main/workflow-templates/ci.yaml
First runs setup action to warm up the cache and then runs detected npm scripts as paralel jobs:
lint:jslint:tslint:csslint:missing-translationslint(if nolint:*scripts present)test:unittest(if notest:*scripts present)build
In many projects you might end up having more than one linter or tester
to run (e.g. eslint+stylelint or jest+playwright). To keep
things handy in the command like, we aim to have npm run lint run all
of the linters, but in the CI we want to run them separately to be able
to see what’s failing more clearly.
What you’ll want to do is install npm-run-all in your project and
have something like:
"scripts": {
"lint": "npm-run-all 'lint:*'",
"lint:js": "eslint .",
"lint:css": "stylelint '**/*.css'"
}Template: https://github.com/verkstedt/.github/tree/main/workflow-templates/chromatic.yaml
Builds StoryBook and publishes to Chromatic.
Runs only on main branch and published PRs.
Requires some vars and/or secrets. See ./.github/workflows/chromatic.yaml for details.
Template: https://github.com/verkstedt/.github/tree/main/workflow-templates/jira.yaml
Moves Jira issues when PRs are created, published or merged.
Requires some vars and/or secrets. See ./.github/workflows/jira.yaml for details.
Template: https://github.com/verkstedt/.github/tree/main/workflow-templates/ref-comment-in-commit.yaml
When a GH commit URL is included in commit message, link the commit from said comment.
Template: https://github.com/verkstedt/.github/tree/main/workflow-templates/create-release.yaml
See create-release.yaml for details.
Template: https://github.com/verkstedt/.github/tree/main/workflow-templates/docker-build-push.yaml
Build Docker image and push it to the registries.
See docker-build-push.yaml for details.
Deploy images to Google Cloud Run services or jobs.
See deploy-cloudrun.yaml for details.
Deploy code to Google Cloud Function.
See deploy-cloudfunction.yaml for details.
You might have noticed that main branch in this repository is called
v1 not main. This means that when something is merged, it will be
picked up by all projects using us @v1. We don’t create any release
git tags.
In case we’d have to introduce any breaking changes we will create a
v2 branch (and set it as default), but we should try hard to avoid
that.
If any of your npm scripts requires any env vars, set env_vars secret
in the repository. Make sure there’s secrets: inherit in your
ci.yaml.
You have two options:
-
Modify your
npm testscript to do the setup for you.Example:
Let’s assume that your
testscript runsjestand you need to runnpx mock-serverbefore.-
Create separate script file, e.g.
./scripts/test.sh:#!/bin/sh set -ue if [ -n "${CI-}" ] then npx mock-server & mock_server_pid=$! trap "kill \"$mock_server_pid\" 2>/dev/null" EXIT SIGINT SIGTERM SIGHUP fi jest "$@"
-
Update script in
package.json:"test": "./scripts/test.sh"
-
-
Don’t use these workflows.
See Goals for this project.
