-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CI: use GitHub actions to configure and build Docker images
- Loading branch information
Showing
1 changed file
with
38 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,51 @@ | ||
name: Image Builder | ||
|
||
on: | ||
push: | ||
# Build and publish after updating the default branch | ||
branches: | ||
- main | ||
paths-ignore: | ||
- '.dockerignore' | ||
- 'docs/*' | ||
- 'LICENSE' | ||
- 'README.md' | ||
- 'example/*' | ||
pull_request: | ||
# Build, but don't push on pull requests | ||
branches: | ||
- main | ||
push: {} | ||
|
||
jobs: | ||
# Build images and push them | ||
build: | ||
name: Build Docker image | ||
name: Build tagged Docker image | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Build image | ||
run: | | ||
docker build \ | ||
--tag=${{ github.repository }} \ | ||
--tag=ghcr.io/${{ github.repository }} \ | ||
. | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKER_HUB_USERNAME }} | ||
password: ${{ secrets.DOCKER_HUB_TOKEN }} | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: | | ||
openjournals/inara | ||
ghcr.io/openjournals/inara | ||
tags: | | ||
type=semver,pattern={{version}} | ||
type=edge,branch=main | ||
- name: Build and push image | ||
id: push | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: '.' | ||
push: true | ||
tags: ${{ steps.meta.output.tags }} | ||
labels: ${{ steps.meta.output.labels }} | ||
|
||
- name: Test image | ||
run: | | ||
make test | ||
- name: Push to Docker Hub | ||
if: >- | ||
github.event_name == 'push' && | ||
github.repository == 'openjournals/inara' | ||
run: | | ||
# Log into registry | ||
echo "${{ secrets.DOCKER_HUB_TOKEN }}" | | ||
docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin | ||
docker push ${{ github.repository }} | ||
- name: Push to GitHub Container Registry | ||
if: >- | ||
github.event_name == 'push' && | ||
github.repository == 'openjournals/inara' | ||
run: | | ||
# Log into registry | ||
echo "${{ secrets.GITHUB_TOKEN }}" | \ | ||
docker login ghcr.io \ | ||
-u ${{ github.actor }} \ | ||
--password-stdin | ||
docker push ghcr.io/${{ github.repository }} | ||
run: make test |