Skip to content

Commit 85c97ee

Browse files
authored
Container based developer flow (#134)
Co-authored-by: CrazyMax <[email protected]>
1 parent ad72f07 commit 85c97ee

File tree

7 files changed

+129
-36
lines changed

7 files changed

+129
-36
lines changed

.dockerignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/.dev
2+
/dist
3+
/lib
4+
/node_modules

.github/CONTRIBUTING.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ Contributions to this project are [released](https://help.github.com/articles/gi
77
## Submitting a pull request
88

99
1. [Fork](https://github.com/crazy-max/ghaction-github-pages/fork) and clone the repository
10-
2. Configure and install the dependencies: `yarn install`
11-
4. Create a new branch: `git checkout -b my-branch-name`
12-
5. Make your change
13-
6. Run pre-checkin: `yarn run pre-checkin`
10+
2. Configure and install the dependencies locally: `yarn install`
11+
3. Create a new branch: `git checkout -b my-branch-name`
12+
4. Make your changes
13+
5. Format code and build javascript artifacts: `docker buildx bake pre-checkin`
14+
6. Validate all code has correctly formatted and built: `docker buildx bake validate`
1415
7. Push to your fork and [submit a pull request](https://github.com/crazy-max/ghaction-github-pages/compare)
1516
8. Pat your self on the back and wait for your pull request to be reviewed and merged.
1617

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ on:
55
- cron: '0 10 * * *' # everyday at 10am
66
push:
77
branches:
8-
- dev
9-
- releases/v*
8+
- 'dev'
9+
- 'releases/v*'
1010

1111
jobs:
1212
ci:

.github/workflows/pre-checkin.yml

Lines changed: 0 additions & 30 deletions
This file was deleted.

.github/workflows/validate.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: validate
2+
3+
on:
4+
push:
5+
branches:
6+
- 'dev'
7+
- 'releases/v*'
8+
paths-ignore:
9+
- '**.md'
10+
pull_request:
11+
branches:
12+
- 'dev'
13+
paths-ignore:
14+
- '**.md'
15+
16+
jobs:
17+
validate:
18+
runs-on: ubuntu-latest
19+
steps:
20+
-
21+
name: Checkout
22+
uses: actions/checkout@v2
23+
-
24+
name: Validate
25+
run: docker buildx bake validate

Dockerfile.dev

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#syntax=docker/dockerfile:1.2
2+
3+
FROM node:12 AS deps
4+
WORKDIR /src
5+
COPY package.json yarn.lock ./
6+
RUN --mount=type=cache,target=/src/node_modules \
7+
yarn install
8+
9+
FROM scratch AS update-yarn
10+
COPY --from=deps /src/yarn.lock /
11+
12+
FROM deps AS validate-yarn
13+
COPY .git .git
14+
RUN status=$(git status --porcelain -- yarn.lock); if [ -n "$status" ]; then echo $status; exit 1; fi
15+
16+
FROM deps AS base
17+
COPY . .
18+
19+
FROM base AS build
20+
RUN --mount=type=cache,target=/src/node_modules \
21+
yarn build
22+
23+
FROM base AS run-format
24+
RUN --mount=type=cache,target=/src/node_modules \
25+
yarn run format
26+
27+
FROM scratch AS format
28+
COPY --from=run-format /src/src/*.ts /src/
29+
30+
FROM base AS validate-format
31+
RUN --mount=type=cache,target=/src/node_modules \
32+
yarn run format-check
33+
34+
FROM scratch AS dist
35+
COPY --from=build /src/dist/ /dist/
36+
37+
FROM build AS validate-build
38+
RUN status=$(git status --porcelain -- dist); if [ -n "$status" ]; then echo $status; exit 1; fi
39+
40+
FROM base AS dev
41+
ENTRYPOINT ["bash"]

docker-bake.hcl

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
variable "GITHUB_REPOSITORY" {
2+
default = "crazy-max/ghaction-github-pages"
3+
}
4+
5+
group "default" {
6+
targets = ["build"]
7+
}
8+
9+
group "pre-checkin" {
10+
targets = ["update-yarn", "format", "build"]
11+
}
12+
13+
group "validate" {
14+
targets = ["validate-format", "validate-build", "validate-yarn"]
15+
}
16+
17+
target "dockerfile" {
18+
dockerfile = "Dockerfile.dev"
19+
}
20+
21+
target "update-yarn" {
22+
inherits = ["dockerfile"]
23+
target = "update-yarn"
24+
output = ["."]
25+
}
26+
27+
target "build" {
28+
inherits = ["dockerfile"]
29+
target = "dist"
30+
output = ["."]
31+
}
32+
33+
target "format" {
34+
inherits = ["dockerfile"]
35+
target = "format"
36+
output = ["."]
37+
}
38+
39+
target "validate-format" {
40+
inherits = ["dockerfile"]
41+
target = "validate-format"
42+
}
43+
44+
target "validate-build" {
45+
inherits = ["dockerfile"]
46+
target = "validate-build"
47+
}
48+
49+
target "validate-yarn" {
50+
inherits = ["dockerfile"]
51+
target = "validate-yarn"
52+
}

0 commit comments

Comments
 (0)