Skip to content

Commit eaa19a7

Browse files
authored
Merge pull request #263 from dockersamples/gha-init
adding GHA for docker builds and dependabot config for GHA
2 parents f379254 + 0f4f923 commit eaa19a7

File tree

4 files changed

+258
-0
lines changed

4 files changed

+258
-0
lines changed

.github/dependabot.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: 2
2+
updates:
3+
# Maintain dependencies for GitHub Actions
4+
- package-ecosystem: "github-actions"
5+
directory: "/"
6+
schedule:
7+
interval: "monthly"
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Build Result
2+
# template source: https://github.com/dockersamples/.github/blob/main/templates/call-docker-build.yaml
3+
4+
on:
5+
# we want pull requests so we can build(test) but not push to image registry
6+
push:
7+
branches:
8+
- 'main'
9+
# only build when important files change
10+
paths:
11+
- 'result/**'
12+
- '.github/workflows/call-docker-build-result.yaml'
13+
pull_request:
14+
branches:
15+
- 'main'
16+
# only build when important files change
17+
paths:
18+
- 'result/**'
19+
- '.github/workflows/call-docker-build-result.yaml'
20+
21+
jobs:
22+
call-docker-build:
23+
24+
name: Result Call Docker Build
25+
26+
uses: dockersamples/.github/.github/workflows/reusable-docker-build.yaml@main
27+
28+
permissions:
29+
contents: read
30+
packages: write # needed to push docker image to ghcr.io
31+
pull-requests: write # needed to create and update comments in PRs
32+
33+
secrets:
34+
35+
# Only needed if with:dockerhub-enable is true below
36+
dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }}
37+
38+
# Only needed if with:dockerhub-enable is true below
39+
dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }}
40+
41+
with:
42+
43+
### REQUIRED
44+
### ENABLE ONE OR BOTH REGISTRIES
45+
### tell docker where to push.
46+
### NOTE if Docker Hub is set to true, you must set secrets above and also add account/repo/tags below
47+
dockerhub-enable: true
48+
ghcr-enable: true
49+
50+
### REQUIRED
51+
### A list of the account/repo names for docker build. List should match what's enabled above
52+
### defaults to:
53+
image-names: |
54+
ghcr.io/dockersamples/example-voting-app-result
55+
# dockersamples/examplevotingapp_result
56+
57+
### REQUIRED set rules for tagging images, based on special action syntax:
58+
### https://github.com/docker/metadata-action#tags-input
59+
### defaults to:
60+
tag-rules: |
61+
type=raw,value=latest,enable=${{ endsWith(github.ref, github.event.repository.default_branch) }}
62+
type=ref,event=pr
63+
type=ref,event=branch
64+
type=semver,pattern={{version}}
65+
type=raw,value=gha-${{ github.run_id }}
66+
67+
### path to where docker should copy files into image
68+
### defaults to root of repository (.)
69+
context: result
70+
71+
### Dockerfile alternate name. Default is Dockerfile (relative to context path)
72+
# file: Containerfile
73+
74+
### build stage to target, defaults to empty, which builds to last stage in Dockerfile
75+
# target:
76+
77+
### platforms to build for, defaults to linux/amd64
78+
### other options: linux/amd64,linux/arm64,linux/arm/v7
79+
platforms: linux/amd64,linux/arm64,linux/arm/v7
80+
81+
### Create a PR comment with image tags and labels
82+
### defaults to false
83+
# comment-enable: false
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Build Vote
2+
# template source: https://github.com/dockersamples/.github/blob/main/templates/call-docker-build.yaml
3+
4+
on:
5+
# we want pull requests so we can build(test) but not push to image registry
6+
push:
7+
branches:
8+
- 'main'
9+
# only build when important files change
10+
paths:
11+
- 'vote/**'
12+
- '.github/workflows/call-docker-build-vote.yaml'
13+
pull_request:
14+
branches:
15+
- 'main'
16+
# only build when important files change
17+
paths:
18+
- 'vote/**'
19+
- '.github/workflows/call-docker-build-vote.yaml'
20+
21+
jobs:
22+
call-docker-build:
23+
24+
name: Vote Call Docker Build
25+
26+
uses: dockersamples/.github/.github/workflows/reusable-docker-build.yaml@main
27+
28+
permissions:
29+
contents: read
30+
packages: write # needed to push docker image to ghcr.io
31+
pull-requests: write # needed to create and update comments in PRs
32+
33+
secrets:
34+
35+
# Only needed if with:dockerhub-enable is true below
36+
dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }}
37+
38+
# Only needed if with:dockerhub-enable is true below
39+
dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }}
40+
41+
with:
42+
43+
### REQUIRED
44+
### ENABLE ONE OR BOTH REGISTRIES
45+
### tell docker where to push.
46+
### NOTE if Docker Hub is set to true, you must set secrets above and also add account/repo/tags below
47+
dockerhub-enable: true
48+
ghcr-enable: true
49+
50+
### REQUIRED
51+
### A list of the account/repo names for docker build. List should match what's enabled above
52+
### defaults to:
53+
image-names: |
54+
ghcr.io/dockersamples/example-voting-app-vote
55+
# dockersamples/examplevotingapp_vote
56+
57+
### REQUIRED set rules for tagging images, based on special action syntax:
58+
### https://github.com/docker/metadata-action#tags-input
59+
### defaults to:
60+
# tag-rules: |
61+
# type=raw,value=latest,enable=${{ endsWith(github.ref, github.event.repository.default_branch) }}
62+
# type=ref,event=pr
63+
# type=ref,event=branch
64+
# type=semver,pattern={{version}}
65+
# type=raw,value=gha-${{ github.run_id }}
66+
67+
### path to where docker should copy files into image
68+
### defaults to root of repository (.)
69+
context: vote
70+
71+
### Dockerfile alternate name. Default is Dockerfile (relative to context path)
72+
# file: Containerfile
73+
74+
### build stage to target, defaults to empty, which builds to last stage in Dockerfile
75+
# target:
76+
77+
### platforms to build for, defaults to linux/amd64
78+
### other options: linux/amd64,linux/arm64,linux/arm/v7
79+
platforms: linux/amd64,linux/arm64,linux/arm/v7
80+
81+
### Create a PR comment with image tags and labels
82+
### defaults to false
83+
# comment-enable: false
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: Build Worker
2+
# template source: https://github.com/dockersamples/.github/blob/main/templates/call-docker-build.yaml
3+
4+
on:
5+
# we want pull requests so we can build(test) but not push to image registry
6+
push:
7+
branches:
8+
- 'main'
9+
# only build when important files change
10+
paths:
11+
- 'worker/**'
12+
- '.github/workflows/call-docker-build-worker.yaml'
13+
pull_request:
14+
branches:
15+
- 'main'
16+
# only build when important files change
17+
paths:
18+
- 'worker/**'
19+
- '.github/workflows/call-docker-build-worker.yaml'
20+
21+
jobs:
22+
call-docker-build:
23+
24+
name: Worker Call Docker Build
25+
26+
uses: dockersamples/.github/.github/workflows/reusable-docker-build.yaml@main
27+
28+
permissions:
29+
contents: read
30+
packages: write # needed to push docker image to ghcr.io
31+
pull-requests: write # needed to create and update comments in PRs
32+
33+
secrets:
34+
35+
# Only needed if with:dockerhub-enable is true below
36+
dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }}
37+
38+
# Only needed if with:dockerhub-enable is true below
39+
dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }}
40+
41+
with:
42+
43+
### REQUIRED
44+
### ENABLE ONE OR BOTH REGISTRIES
45+
### tell docker where to push.
46+
### NOTE if Docker Hub is set to true, you must set secrets above and also add account/repo/tags below
47+
dockerhub-enable: true
48+
ghcr-enable: true
49+
50+
### REQUIRED
51+
### A list of the account/repo names for docker build. List should match what's enabled above
52+
### defaults to:
53+
image-names: |
54+
ghcr.io/dockersamples/example-voting-app-worker
55+
# dockersamples/examplevotingapp_worker
56+
57+
### REQUIRED set rules for tagging images, based on special action syntax:
58+
### https://github.com/docker/metadata-action#tags-input
59+
### defaults to:
60+
# tag-rules: |
61+
# type=raw,value=latest,enable=${{ endsWith(github.ref, github.event.repository.default_branch) }}
62+
# type=ref,event=pr
63+
# type=ref,event=branch
64+
# type=semver,pattern={{version}}
65+
# type=raw,value=gha-${{ github.run_id }}
66+
67+
### path to where docker should copy files into image
68+
### defaults to root of repository (.)
69+
context: worker
70+
71+
### Dockerfile alternate name. Default is Dockerfile (relative to context path)
72+
# file: Containerfile
73+
74+
### build stage to target, defaults to empty, which builds to last stage in Dockerfile
75+
# target:
76+
77+
### platforms to build for, defaults to linux/amd64
78+
### other options: linux/amd64,linux/arm64,linux/arm/v7
79+
# FIXME worker arm/v7 support doesn't build in .net core 3.1 with QEMU
80+
# a fix would likely run the .net build on amd64 but with a target of arm/v7
81+
platforms: linux/amd64,linux/arm64
82+
83+
### Create a PR comment with image tags and labels
84+
### defaults to false
85+
# comment-enable: false

0 commit comments

Comments
 (0)