Skip to content

Commit beea99c

Browse files
committed
feat: publish docker image on dockerhub
1 parent 1d6a59a commit beea99c

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Publish docker image
2+
3+
on:
4+
push:
5+
branches:
6+
# todo: Replace with `main` in the final version
7+
- "docker"
8+
- "releases/v*"
9+
tags:
10+
- "v*"
11+
pull_request:
12+
branches:
13+
# todo: Replace with `main` in the final version
14+
- "docker"
15+
- "releases/v*"
16+
17+
env:
18+
# todo: Replace with `torrust/torrust-tracker` in the final version
19+
DOCKER_IMAGE: josecelano/torrust-tracker
20+
21+
jobs:
22+
dockerhub:
23+
runs-on: ubuntu-latest
24+
environment: dockerhub-josecelano
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v3
28+
29+
- name: Docker meta
30+
id: meta
31+
uses: docker/metadata-action@v4
32+
with:
33+
images: |
34+
${{ env.DOCKER_IMAGE }}
35+
tags: |
36+
type=ref,event=branch
37+
type=ref,event=pr
38+
type=semver,pattern={{version}}
39+
type=semver,pattern={{major}}.{{minor}}
40+
41+
- name: Login to Docker Hub
42+
uses: docker/login-action@v2
43+
with:
44+
username: ${{ secrets.DOCKER_HUB_USERNAME }}
45+
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
46+
47+
- name: Set up Docker Buildx
48+
uses: docker/setup-buildx-action@v2
49+
50+
- name: Build and push
51+
uses: docker/build-push-action@v3
52+
with:
53+
context: .
54+
file: ./Dockerfile
55+
push: ${{ github.event_name != 'pull_request' }}
56+
tags: ${{ steps.meta.outputs.tags }}
57+
labels: ${{ steps.meta.outputs.labels }}
58+
cache-from: type=gha
59+
cache-to: type=gha,mode=max

cSpell.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@
99
"Bitflu",
1010
"bools",
1111
"bufs",
12+
"Buildx",
1213
"byteorder",
1314
"canonicalize",
1415
"canonicalized",
1516
"chrono",
1617
"clippy",
1718
"completei",
19+
"dockerhub",
1820
"downloadedi",
1921
"filesd",
2022
"Freebox",

0 commit comments

Comments
 (0)