Skip to content

Commit 84cdbb0

Browse files
committed
Adds workflow to publish container image to dockerhub and ghcr
1 parent 047eba0 commit 84cdbb0

3 files changed

Lines changed: 84 additions & 23 deletions

File tree

.github/workflows/build.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Build, test, and publish container image
2+
3+
on:
4+
# Run pull requests against the default branch
5+
pull_request:
6+
branches: [master]
7+
8+
# Run on push to default branch
9+
push:
10+
branches: [master]
11+
12+
# Run when a release is created
13+
release:
14+
types: [released]
15+
16+
jobs:
17+
build:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Clone this git repository
21+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
22+
23+
- name: Docker meta
24+
if: github.event_name != 'pull_request'
25+
id: meta
26+
uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804
27+
with:
28+
# list of Docker images to use as base name for tags
29+
images: |
30+
plus3it/tardigrade-ci
31+
ghcr.io/plus3it/tardigrade-ci
32+
flavor: |
33+
latest=false
34+
# generate Docker tags based on the following events/attributes
35+
tags: |
36+
# set latest tag for default branch
37+
type=raw,value=latest,enable={{is_default_branch}}
38+
# set version tags for releases
39+
type=semver,pattern={{version}}
40+
type=semver,pattern={{major}}.{{minor}}
41+
type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }}
42+
43+
- name: Login to Docker Hub
44+
if: github.event_name != 'pull_request'
45+
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772
46+
with:
47+
username: ${{ vars.DOCKERHUB_USERNAME }}
48+
password: ${{ secrets.DOCKERHUB_TOKEN }}
49+
50+
- name: Login to GitHub Container Registry
51+
if: github.event_name != 'pull_request'
52+
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772
53+
with:
54+
registry: ghcr.io
55+
username: ${{ github.repository_owner }}
56+
password: ${{ secrets.GITHUB_TOKEN }}
57+
58+
- name: Set up QEMU
59+
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392
60+
61+
- name: Set up Docker Buildx
62+
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2
63+
64+
- name: Build and export
65+
uses: docker/build-push-action@14487ce63c7a62a4a324b0bfb37086795e31c6c1
66+
with:
67+
context: .
68+
load: true
69+
tags: plus3it/tardigrade-ci:test
70+
build-args: |
71+
GITHUB_ACCESS_TOKEN=${{ secrets.GH_READONLY_TOKEN }}
72+
73+
- name: Run bats tests
74+
if: github.event_name == 'pull_request'
75+
run: docker run --rm plus3it/tardigrade-ci:test bats/test
76+
77+
- name: Push to registries
78+
if: github.event_name != 'pull_request'
79+
uses: docker/build-push-action@14487ce63c7a62a4a324b0bfb37086795e31c6c1
80+
with:
81+
push: true
82+
tags: ${{ steps.meta.outputs.tags }}
83+
labels: ${{ steps.meta.outputs.labels }}

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
# Run on demand
55
workflow_dispatch:
66

7-
# Run on push to main when .bumpversion.cfg version is updated
7+
# Run on push to default branch when .bumpversion.cfg version is updated
88
push:
99
branches:
1010
- main

.github/workflows/test.yml

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)