Update docker-image.yml

This commit is contained in:
binary-husky 2023-05-07 16:08:03 +08:00 committed by GitHub
parent 41f801129a
commit da4e483d80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,39 +1,44 @@
name: Build and push Docker image
# https://docs.github.com/en/actions/publishing-packages/publishing-docker-images#publishing-images-to-github-packages
name: Create and publish a Docker image
on:
push:
branches:
- master
- 'master'
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
IMAGE_NAME: gpt-academic-nolocal
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
# Checkout the repository
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3
# Configure Docker Buildx
- name: Configure Docker Buildx
run: |
docker buildx create --name builder
docker buildx use builder
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Set up GitHub Packages registry
- name: Set up GitHub Packages registry
run: echo "${DOCKER_PASSWORD}" | docker login ghcr.io -u "${DOCKER_USERNAME}" --password-stdin
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# Build and push the Docker image
- name: Build and push Docker image
uses: docker/build-push-action@v2
uses: docker/build-push-action@v4
with:
context: .
dockerfile: docs/DockerfileNoLocal
push: true
tags: ghcr.io/${{ github.repository }}/${{ env.IMAGE_NAME }}:latest
dockerfile: docs/Dockerfile+NoLocal
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}