Skip to content

Commit ce6a3f5

Browse files
committed
Build the image and test it
1 parent 8600045 commit ce6a3f5

File tree

1 file changed

+30
-9
lines changed

1 file changed

+30
-9
lines changed

.github/workflows/main.yml

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
env:
2+
CONTAINER_IMAGE_TAG: githubchangeloggenerator/github-changelog-generator:latest
3+
14
name: Build and deploy latest image
25

36
on: [push, pull_request]
47

58
jobs:
6-
build:
9+
lint:
710
name: Lint the codebase
811
runs-on: ubuntu-20.04
912
steps:
@@ -15,28 +18,46 @@ jobs:
1518
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1619
LINTER_RULES_PATH: .
1720
VALIDATE_ALL_CODEBASE: true
18-
push:
19-
if: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')) }}
20-
environment: Docker Hub
21-
name: Deploy latest image (Docker Hub)
22-
needs: build
21+
build:
22+
name: Build and test the container image
23+
needs: lint
2324
runs-on: ubuntu-20.04
2425
steps:
2526
- uses: actions/[email protected]
2627
- name: Setup Docker Buildx
2728
uses: docker/setup-buildx-action@v1
2829
- name: Set up QEMU
2930
uses: docker/setup-qemu-action@v1
31+
- name: Build the container image for x86_64 only
32+
uses: docker/build-push-action@v2
33+
with:
34+
context: .
35+
file: ./Dockerfile
36+
platforms: linux/amd64
37+
push: false
38+
tags: ${{ env.CONTAINER_IMAGE_TAG }}
39+
- name: Test the container image
40+
shell: bash
41+
run: docker run ${{ env.CONTAINER_IMAGE_TAG }}
42+
deploy:
43+
env:
44+
PUSH_IMAGES: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
45+
environment: Docker Hub
46+
if: ${{ env.PUSH_IMAGES }}
47+
name: Deploy the container image
48+
needs: build
49+
runs-on: ubuntu-20.04
50+
steps:
3051
- name: Login to Docker Hub
3152
uses: docker/login-action@v1
3253
with:
3354
username: ${{ secrets.DOCKERHUB_USERNAME }}
3455
password: ${{ secrets.DOCKERHUB_TOKEN }}
35-
- name: Push to Docker Hub (latest)
56+
- name: Build the contaiiner image for all the platforms and eventually push to Docker Hub (latest)
3657
uses: docker/build-push-action@v2
3758
with:
3859
context: .
3960
file: ./Dockerfile
4061
platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x
41-
push: true
42-
tags: githubchangeloggenerator/github-changelog-generator:latest
62+
push: ${{ env.PUSH_IMAGES }}
63+
tags: ${{ env.CONTAINER_IMAGE_TAG }}

0 commit comments

Comments
 (0)