This commit is contained in:
parent
6c7c958a09
commit
96043432a1
28
.github/workflows/docker-image.yml
vendored
28
.github/workflows/docker-image.yml
vendored
@ -14,7 +14,6 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
env:
|
||||||
DH_REGISTRY: docker.io
|
DH_REGISTRY: docker.io
|
||||||
GH_REGISTRY: ghcr.io
|
|
||||||
IMAGE_NAME: ${{ github.repository }}
|
IMAGE_NAME: ${{ github.repository }}
|
||||||
REPOSITORY: ${{ github.event.repository.name }}
|
REPOSITORY: ${{ github.event.repository.name }}
|
||||||
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
||||||
@ -31,40 +30,29 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
echo "DOCKER_USERNAME=remote" >> $GITHUB_ENV
|
echo "DOCKER_USERNAME=remote" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Build the Docker image
|
- name: determine deployment
|
||||||
run: docker build --pull . --file Dockerfile --tag "$DOCKER_USERNAME/$REPOSITORY:latest"
|
if: github.ref == 'refs/heads/master' && ( github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' )
|
||||||
|
run: echo "DEPLOY=true" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Log in to Docker Hub
|
- name: Log in to Docker Hub
|
||||||
uses: docker/login-action@v1
|
uses: docker/login-action@v1
|
||||||
if: github.ref == 'refs/heads/master' && (github.event_name == 'push' || github.event_name == 'schedule')
|
if: env.DEPLOY == 'true'
|
||||||
with:
|
with:
|
||||||
registry: ${{ env.DH_REGISTRY }}
|
registry: ${{ env.DH_REGISTRY }}
|
||||||
username: ${{ env.DOCKER_USERNAME }}
|
username: ${{ env.DOCKER_USERNAME }}
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
|
||||||
- name: Push to Docker Hub
|
|
||||||
if: github.ref == 'refs/heads/master' && (github.event_name == 'push' || github.event_name == 'schedule')
|
|
||||||
run: docker push "$DOCKER_USERNAME/$REPOSITORY:latest"
|
|
||||||
|
|
||||||
- name: Log in to the Container registry
|
|
||||||
uses: docker/login-action@v1
|
|
||||||
with:
|
|
||||||
registry: ${{ env.GH_REGISTRY }}
|
|
||||||
username: ${{ github.actor }}
|
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Extract metadata (tags, labels) for Docker
|
- name: Extract metadata (tags, labels) for Docker
|
||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@v3
|
uses: docker/metadata-action@v3
|
||||||
with:
|
with:
|
||||||
images: ${{ env.GH_REGISTRY }}/${{ env.IMAGE_NAME }}
|
images: ${{ env.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}
|
||||||
|
tags: type=raw,value=latest
|
||||||
|
|
||||||
- name: Push to GitHub
|
- name: Push to Docker Hub
|
||||||
uses: docker/build-push-action@v2
|
uses: docker/build-push-action@v2
|
||||||
if: github.event_name == 'push' || github.event_name == 'schedule'
|
|
||||||
with:
|
with:
|
||||||
|
push: ${{ env.DEPLOY }}
|
||||||
context: .
|
context: .
|
||||||
push: true
|
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user