docker: publish to github container registry

This commit is contained in:
nadoo 2020-11-12 23:39:54 +08:00
parent 678e9b9845
commit da1075116f

View File

@ -1,3 +1,5 @@
# https://github.com/docker/build-push-action#usage
name: Docker
on:
push:
@ -38,6 +40,13 @@ jobs:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build dev branch and push
if: github.ref == 'refs/heads/dev'
uses: docker/build-push-action@v2
@ -45,7 +54,9 @@ jobs:
context: .
platforms: linux/amd64,linux/arm/v7,linux/arm64
push: true
tags: 'nadoo/glider:dev'
tags: 'nadoo/glider:dev,ghcr.io/nadoo/glider:dev'
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache
- name: Get all docker tags
if: startsWith(github.ref, 'refs/tags/')
@ -53,9 +64,12 @@ jobs:
id: tags
with:
script: |
const ref = `${context.payload.ref.replace(/\/?refs\/tags\//, '')}`
const tags = [
'nadoo/glider:latest',
`nadoo/glider:${context.payload.ref.replace(/\/?refs\/tags\//, '')}`
`nadoo/glider:${ref}`,
'ghcr.io/nadoo/glider:latest',
`ghcr.io/nadoo/glider:${ref}`
]
return tags.join(',')
result-encoding: string
@ -68,3 +82,5 @@ jobs:
platforms: linux/amd64,linux/arm/v7,linux/arm64
push: true
tags: ${{steps.tags.outputs.result}}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache