push to ghcr

This commit is contained in:
BennyThink 2021-12-26 18:49:47 +08:00
parent 48fe83b6b8
commit 5f19a51a9b
No known key found for this signature in database
GPG Key ID: 6CD0DBDA5235D481

View File

@ -1,3 +1,4 @@
name: docker image builder
on: on:
push: push:
branches: branches:
@ -32,19 +33,35 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }} username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }} password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Lower case - name: Login to GitHub Container Registry
id: string uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Lower case for Docker Hub
id: dh_string
uses: ASzc/change-string-case-action@v1 uses: ASzc/change-string-case-action@v1
with: with:
string: ${{ secrets.DOCKERHUB_USERNAME }}/${{ github.event.repository.name }} string: ${{ secrets.DOCKERHUB_USERNAME }}/${{ github.event.repository.name }}
- name: Lower case for ghcr
id: ghcr_string
uses: ASzc/change-string-case-action@v1
with:
string: ${{ github.event.repository.full_name }}
- name: Build and push - name: Build and push
uses: docker/build-push-action@v2 uses: docker/build-push-action@v2
with: with:
context: . context: .
platforms: linux/arm,linux/amd64,linux/arm64 platforms: linux/arm,linux/amd64,linux/arm64
push: true push: true
tags: ${{ steps.string.outputs.lowercase }} tags: |
${{ steps.dh_string.outputs.lowercase }}
ghcr.io/${{ steps.ghcr_string.outputs.lowercase }}
cache-from: type=local,src=/tmp/.buildx-cache cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max