build docker image on push to main
This commit is contained in:
parent
75d7307134
commit
5e4c3bb21a
1 changed files with 63 additions and 0 deletions
63
.github/workflows/docker-hub-build-push-on-push.yml
vendored
Normal file
63
.github/workflows/docker-hub-build-push-on-push.yml
vendored
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
name: Build docker image and push to docker hub on release
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
env:
|
||||
PLATFORMS: "linux/amd64,linux/386,linux/arm64,linux/arm/v7,linux/arm/v6,linux/s390x"
|
||||
|
||||
jobs:
|
||||
build_and_push:
|
||||
name: Build and push Docker image
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Extract tag string
|
||||
id: git
|
||||
shell: bash
|
||||
run: |
|
||||
RELEASE_VERSION="dev-$(date +%s)"
|
||||
echo "::set-output name=image_tag::${RELEASE_VERSION}"
|
||||
echo "Action image_tag=${RELEASE_VERSION}"
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
|
||||
- name: Install buildx
|
||||
uses: docker/setup-buildx-action@v2.1.0
|
||||
|
||||
- name: Login to docker hub
|
||||
uses: docker/login-action@v2.1.0
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v2.1.0
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.repository_owner }}
|
||||
password: ${{ github.token }}
|
||||
|
||||
- name: Build and push ${{ github.repository }}:${{ steps.git.outputs.image_tag }}
|
||||
uses: docker/build-push-action@v3.2.0
|
||||
with:
|
||||
platforms: ${{ env.PLATFORMS }}
|
||||
push: true
|
||||
tags: |
|
||||
${{ github.repository }}:${{ steps.git.outputs.image_tag }}
|
||||
${{ github.repository }}:develop
|
||||
ghcr.io/${{ github.repository }}:${{ steps.git.outputs.image_tag }}
|
||||
ghcr.io/${{ github.repository }}:develop
|
||||
|
||||
- name: Update dockerhub description
|
||||
uses: peter-evans/dockerhub-description@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
||||
repository: ${{ github.repository }}
|
||||
short-description: ${{ github.event.repository.description }}
|
||||
Loading…
Reference in a new issue