Skip to content

Commit b497244

Browse files
JamesMConroyJames Conroy
and
James Conroy
authored
Add Workflow to Build, Test, and Publish Image (panamax-rs#66)
* Add workflow to build and test container This is so we can get immediat feedback when the container is broken * don't try to push the container * Add a simpler job to build and test the image We don't need the full docker build push action just to test the image. If the build and test succeeds then we can use the full action. * Don't set up qemu in test stage Also set the tag to the project's name * Only run actions on pushes to master and PRs We don't need the container created on all pushes for every feature branch. Co-authored-by: James Conroy <[email protected]>
1 parent 5ac96cf commit b497244

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

.github/workflows/container-test.yml

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
name: ci
3+
4+
on:
5+
pull_request:
6+
push:
7+
branches:
8+
- master
9+
10+
env:
11+
CONTAINER_NAME: panamax-rs/panamax
12+
13+
jobs:
14+
test:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v2
20+
21+
- name: Test building image
22+
run: docker build -t ${{ env.CONTAINER_NAME }}:test .
23+
24+
- name: Run the built image
25+
run: docker run --rm ${{ env.CONTAINER_NAME }}:test
26+
27+
release:
28+
name: Release
29+
runs-on: ubuntu-latest
30+
needs: test
31+
if: github.ref == 'refs/heads/master'
32+
33+
steps:
34+
- uses: actions/checkout@v2
35+
- uses: docker/setup-qemu-action@v1
36+
- uses: docker/setup-buildx-action@v1
37+
38+
- name: Login to DockerHub
39+
uses: docker/login-action@v2
40+
with:
41+
username: ${{ secrets.DOCKERHUB_USERNAME }}
42+
password: ${{ secrets.DOCKERHUB_TOKEN }}
43+
44+
- name: Build and export to Docker
45+
uses: docker/build-push-action@v3
46+
with:
47+
context: .
48+
load: true
49+
tags: ${{ env.TEST_TAG }}
50+
51+
- name: Build and push
52+
uses: docker/build-push-action@v3
53+
with:
54+
context: .
55+
platforms: linux/amd64,linux/arm64
56+
push: false
57+
tags: ${{ env.CONTAINER_NAME }}:latest
58+
...

0 commit comments

Comments
 (0)