Skip to content

Commit

Permalink
Use github container registry
Browse files Browse the repository at this point in the history
  • Loading branch information
wenxuanjun committed Apr 30, 2024
1 parent 76b429f commit 07b2a30
Showing 1 changed file with 32 additions and 12 deletions.
44 changes: 32 additions & 12 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,37 @@ on:
jobs:
build:
runs-on: ubuntu-latest

permissions:
packages: write
contents: read

env:
tag: ${{ secrets.CI_REGISTRY }}/geekpie/lug:latest
REGISTRY: ghcr.io
USERNAME: ShanghaitechGeekPie
IMAGE_NAME : ${{ github.repository }}

steps:
- uses: actions/checkout@v3
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
registry: ${{ secrets.CI_REGISTRY }}
username: ${{ secrets.CI_REGISTRY_USER }}
password: ${{ secrets.CI_REGISTRY_PASSWORD }}
- name: Build the Docker image
run: docker build . --file Dockerfile --tag $tag
- name: Push the Docker image
run: docker push $tag
- name: Checkout repository
uses: actions/checkout@v3

- name: Login to Container registry
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ env.USERNAME }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

0 comments on commit 07b2a30

Please sign in to comment.