diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 6491d65..82d7a49 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -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 }} \ No newline at end of file