Skip to content

Commit

Permalink
Merge pull request #1 from e7d/feat/main/github-actions
Browse files Browse the repository at this point in the history
Build Docker Images through Docker Actions
  • Loading branch information
e7d authored Mar 28, 2024
2 parents abe7cd4 + 646a4c0 commit 2f3a123
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: docker-image

on:
push:
tags:
- "*"
branches:
- "main"
pull_request:
branches:
- "main"

jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and export
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x
cache-from: type=registry,ref=${{ vars.DOCKERHUB_IMAGE }}:buildcache
cache-to: type=registry,ref=${{ vars.DOCKERHUB_IMAGE }}:buildcache,mode=max
push: true
tags: ${{ vars.DOCKERHUB_IMAGE }}:${{ github.sha }}
- name: Push "tag"
if: github.ref_type == 'tag'
run: |
GITHUB_REF=${{ github.ref }}
TAG=${GITHUB_REF#refs/tags/}
docker buildx imagetools create \
--tag ${{ vars.DOCKERHUB_IMAGE }}:${TAG} \
${{ vars.DOCKERHUB_IMAGE }}:${{ github.sha }}
- name: Push "latest"
if: github.ref == 'refs/heads/main'
run: |
docker buildx imagetools create \
--tag ${{ vars.DOCKERHUB_IMAGE }}:latest \
${{ vars.DOCKERHUB_IMAGE }}:${{ github.sha }}
- name: Update repo description
if: github.ref == 'refs/heads/main'
uses: peter-evans/dockerhub-description@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: ${{ vars.DOCKERHUB_IMAGE }}

0 comments on commit 2f3a123

Please sign in to comment.