Skip to content

Commit 3600347

Browse files
committed
CI: use GitHub actions to configure and build Docker images
1 parent fc582d8 commit 3600347

File tree

1 file changed

+38
-46
lines changed

1 file changed

+38
-46
lines changed

.github/workflows/build.yaml

Lines changed: 38 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,51 @@
11
name: Image Builder
22

33
on:
4-
push:
5-
# Build and publish after updating the default branch
6-
branches:
7-
- main
8-
paths-ignore:
9-
- '.dockerignore'
10-
- 'docs/*'
11-
- 'LICENSE'
12-
- 'README.md'
13-
- 'example/*'
14-
pull_request:
15-
# Build, but don't push on pull requests
16-
branches:
17-
- main
4+
push: {}
185

196
jobs:
207
# Build images and push them
218
build:
22-
name: Build Docker image
9+
name: Build tagged Docker image
2310
runs-on: ubuntu-latest
2411

2512
steps:
26-
- uses: actions/checkout@v4
13+
- name: Checkout repository
14+
uses: actions/checkout@v4
2715

28-
- name: Build image
29-
run: |
30-
docker build \
31-
--tag=${{ github.repository }} \
32-
--tag=ghcr.io/${{ github.repository }} \
33-
.
16+
17+
- name: Login to Docker Hub
18+
uses: docker/login-action@v3
19+
with:
20+
username: ${{ secrets.DOCKER_HUB_USERNAME }}
21+
password: ${{ secrets.DOCKER_HUB_TOKEN }}
22+
23+
- name: Login to GitHub Container Registry
24+
uses: docker/login-action@v3
25+
with:
26+
registry: ghcr.io
27+
username: ${{ github.actor }}
28+
password: ${{ secrets.GITHUB_TOKEN }}
29+
30+
- name: Docker meta
31+
id: meta
32+
uses: docker/metadata-action@v5
33+
with:
34+
images: |
35+
openjournals/inara
36+
ghcr.io/openjournals/inara
37+
tags: |
38+
type=semver,pattern={{version}}
39+
type=edge,branch=main
40+
41+
- name: Build and push image
42+
id: push
43+
uses: docker/build-push-action@v5
44+
with:
45+
context: '.'
46+
push: true
47+
tags: ${{ steps.meta.output.tags }}
48+
labels: ${{ steps.meta.output.labels }}
3449

3550
- name: Test image
36-
run: |
37-
make test
38-
39-
- name: Push to Docker Hub
40-
if: >-
41-
github.event_name == 'push' &&
42-
github.repository == 'openjournals/inara'
43-
run: |
44-
# Log into registry
45-
echo "${{ secrets.DOCKER_HUB_TOKEN }}" |
46-
docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin
47-
docker push ${{ github.repository }}
48-
49-
- name: Push to GitHub Container Registry
50-
if: >-
51-
github.event_name == 'push' &&
52-
github.repository == 'openjournals/inara'
53-
run: |
54-
# Log into registry
55-
echo "${{ secrets.GITHUB_TOKEN }}" | \
56-
docker login ghcr.io \
57-
-u ${{ github.actor }} \
58-
--password-stdin
59-
docker push ghcr.io/${{ github.repository }}
51+
run: make test

0 commit comments

Comments
 (0)