Skip to content

Commit b561095

Browse files
authored
Merge pull request #10 from smlx/build-image
feat: also build an image
2 parents 0a85601 + 2cdaf04 commit b561095

File tree

6 files changed

+145
-0
lines changed

6 files changed

+145
-0
lines changed

.github/dependabot.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
version: 2
22
updates:
3+
- package-ecosystem: docker
4+
directory: /
5+
schedule:
6+
interval: daily
37
- package-ecosystem: github-actions
48
directory: /
59
schedule:

.github/workflows/build.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,41 @@ jobs:
2828
with:
2929
name: dist.tar
3030
path: dist.tar
31+
buildimage:
32+
if: ${{ !startsWith(github.head_ref, 'dependabot/') }}
33+
strategy:
34+
matrix:
35+
binary:
36+
- go-cli-github
37+
needs: build
38+
runs-on: ubuntu-latest
39+
steps:
40+
- name: Checkout
41+
uses: actions/checkout@v3
42+
- name: Download binaries tar file
43+
uses: actions/download-artifact@v3
44+
with:
45+
name: dist.tar
46+
- name: Untar binaries
47+
run: tar -xvf dist.tar
48+
- name: Login to GHCR
49+
uses: docker/login-action@v2
50+
with:
51+
registry: ghcr.io
52+
username: ${{ github.repository_owner }}
53+
password: ${{ secrets.GITHUB_TOKEN }}
54+
- name: Docker metadata
55+
# this id is namespaced per matrix run
56+
id: docker_metadata
57+
uses: docker/metadata-action@v4
58+
with:
59+
images: ghcr.io/${{ github.repository }}/${{ matrix.binary }}
60+
- name: Build and push ${{ matrix.binary }} container image
61+
id: docker_build
62+
uses: docker/build-push-action@v3
63+
with:
64+
push: true
65+
tags: ${{ steps.docker_metadata.outputs.tags }}
66+
labels: ${{ steps.docker_metadata.outputs.labels }}
67+
file: deploy/${{ matrix.binary }}/Dockerfile
68+
context: dist/${{ matrix.binary }}_linux_amd64_v1

.github/workflows/release.yaml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,52 @@ jobs:
5757
args: release --rm-dist
5858
env:
5959
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
60+
- name: Tar up binaries
61+
run: tar -cvf dist.tar dist
62+
- name: Upload binaries tar file
63+
uses: actions/upload-artifact@v3
64+
with:
65+
name: dist.tar
66+
path: dist.tar
67+
releaseimage:
68+
strategy:
69+
matrix:
70+
binary:
71+
- go-cli-github
72+
needs:
73+
- tag
74+
- release
75+
runs-on: ubuntu-latest
76+
steps:
77+
- name: Checkout
78+
uses: actions/checkout@v3
79+
- name: Download binaries tar file
80+
uses: actions/download-artifact@v3
81+
with:
82+
name: dist.tar
83+
- name: Untar binaries
84+
run: tar -xvf dist.tar
85+
- name: Login to GHCR
86+
uses: docker/login-action@v2
87+
with:
88+
registry: ghcr.io
89+
username: ${{ github.repository_owner }}
90+
password: ${{ secrets.GITHUB_TOKEN }}
91+
- name: Docker metadata
92+
# this id is namespaced per matrix run
93+
id: docker_metadata
94+
uses: docker/metadata-action@v4
95+
with:
96+
images: ghcr.io/${{ github.repository }}/${{ matrix.binary }}
97+
tags: |
98+
${{ needs.tag.outputs.new-tag-version }}
99+
latest
100+
- name: Build and push ${{ matrix.binary }} container image
101+
id: docker_build
102+
uses: docker/build-push-action@v3
103+
with:
104+
push: true
105+
tags: ${{ steps.docker_metadata.outputs.tags }}
106+
labels: ${{ steps.docker_metadata.outputs.labels }}
107+
file: deploy/${{ matrix.binary }}/Dockerfile
108+
context: dist/${{ matrix.binary }}_linux_amd64_v1

.github/workflows/tag-to-release.yaml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,52 @@ jobs:
2222
args: release --rm-dist
2323
env:
2424
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25+
- name: Tar up binaries
26+
run: tar -cvf dist.tar dist
27+
- name: Upload binaries tar file
28+
uses: actions/upload-artifact@v3
29+
with:
30+
name: dist.tar
31+
path: dist.tar
32+
releaseimage:
33+
strategy:
34+
matrix:
35+
binary:
36+
- go-cli-github
37+
needs:
38+
- tag
39+
- release
40+
runs-on: ubuntu-latest
41+
steps:
42+
- name: Checkout
43+
uses: actions/checkout@v3
44+
- name: Download binaries tar file
45+
uses: actions/download-artifact@v3
46+
with:
47+
name: dist.tar
48+
- name: Untar binaries
49+
run: tar -xvf dist.tar
50+
- name: Login to GHCR
51+
uses: docker/login-action@v2
52+
with:
53+
registry: ghcr.io
54+
username: ${{ github.repository_owner }}
55+
password: ${{ secrets.GITHUB_TOKEN }}
56+
- name: Docker metadata
57+
# this id is namespaced per matrix run
58+
id: docker_metadata
59+
uses: docker/metadata-action@v4
60+
with:
61+
images: ghcr.io/${{ github.repository }}/${{ matrix.binary }}
62+
tags: |
63+
${{ needs.tag.outputs.new-tag-version }}
64+
latest
65+
- name: Build and push ${{ matrix.binary }} container image
66+
id: docker_build
67+
uses: docker/build-push-action@v3
68+
with:
69+
push: true
70+
tags: ${{ steps.docker_metadata.outputs.tags }}
71+
labels: ${{ steps.docker_metadata.outputs.labels }}
72+
file: deploy/${{ matrix.binary }}/Dockerfile
73+
context: dist/${{ matrix.binary }}_linux_amd64_v1

.github/workflows/test.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ jobs:
66
steps:
77
- name: Checkout
88
uses: actions/checkout@v3
9+
with:
10+
ref: ${{ github.event.pull_request.head.sha }}
911
- name: Install Go
1012
uses: actions/setup-go@v3
1113
with:

deploy/go-cli-github/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM alpine:3.16
2+
ENTRYPOINT ["/go-cli-github"]
3+
COPY go-cli-github /

0 commit comments

Comments
 (0)