Skip to content

Commit

Permalink
Update docker-image.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
souramoo authored Apr 7, 2022
1 parent acef339 commit 18c65c5
Showing 1 changed file with 28 additions and 25 deletions.
53 changes: 28 additions & 25 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
name: Docker Image CI

on:
release:
types: [published]

env:
PLATFORMS: amd64,arm,arm64,riscv64
workflow_dispatch:

jobs:
build:
Expand All @@ -17,29 +13,36 @@ jobs:

- name: Set up QEMU
uses: docker/setup-qemu-action@v1
with:
platforms: ${{ env.PLATFORMS }}

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

- name: Log in to Docker Hub
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
install: true
version: latest
driver-opts: image=moby/buildkit:latest

- name: Build the Docker image
run: docker build . --file Dockerfile --tag caroga/commentoplusplus:latest

- name: Login to Docker Hub
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Tag the image
run: docker tag caroga/commentoplusplus:latest caroga/commentoplusplus:"$TAG"
env:
TAG: ${{ github.event.release.tag_name }}
- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%Y-%m-%d')"

- name: Push the image to Docker Hub
run: docker push caroga/commentoplusplus:latest && docker push caroga/commentoplusplus:"$TAG"
env:
TAG: ${{ github.event.release.tag_name }}
- name: Build image and push to Docker Hub and GitHub Container Registry
uses: docker/build-push-action@v2
with:
context: .
tags: |
caroga/commentoplusplus:latest
caroga/commentoplusplus:"${{ steps.date.outputs.date }}"
ghcr.io/souramoo/commentoplusplus:latest
ghcr.io/souramoo/commentoplusplus:"${{ steps.date.outputs.date }}"
# build on feature branches, push only on main branch
push: ${{ github.ref == 'refs/heads/main' }}
platforms: amd64,arm,arm64,riscv64

0 comments on commit 18c65c5

Please sign in to comment.