Skip to content

Commit

Permalink
feat: publish docker image on dockerhub
Browse files Browse the repository at this point in the history
  • Loading branch information
josecelano committed Dec 8, 2022
1 parent 1d6a59a commit beea99c
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/publish-docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Publish docker image

on:
push:
branches:
# todo: Replace with `main` in the final version
- "docker"
- "releases/v*"
tags:
- "v*"
pull_request:
branches:
# todo: Replace with `main` in the final version
- "docker"
- "releases/v*"

env:
# todo: Replace with `torrust/torrust-tracker` in the final version
DOCKER_IMAGE: josecelano/torrust-tracker

jobs:
dockerhub:
runs-on: ubuntu-latest
environment: dockerhub-josecelano
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
${{ env.DOCKER_IMAGE }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
2 changes: 2 additions & 0 deletions cSpell.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
"Bitflu",
"bools",
"bufs",
"Buildx",
"byteorder",
"canonicalize",
"canonicalized",
"chrono",
"clippy",
"completei",
"dockerhub",
"downloadedi",
"filesd",
"Freebox",
Expand Down

0 comments on commit beea99c

Please sign in to comment.