diff --git a/.github/workflows/docker_build_and_publish.yml b/.github/workflows/docker_build_and_publish.yml new file mode 100644 index 0000000..4d201c6 --- /dev/null +++ b/.github/workflows/docker_build_and_publish.yml @@ -0,0 +1,41 @@ +name: Build and Publish Docker Image + +on: + push: + tags: + - '*' + +jobs: + build_and_push: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract tag name + shell: bash + run: echo "TAG_NAME=$(echo ${GITHUB_REF#refs/tags/})" >> $GITHUB_ENV + + - name: Build and push Docker image with tag + uses: docker/build-push-action@v2 + with: + context: . + push: true + tags: ghcr.io/${{ github.repository_owner }}/ro-dou:${{ env.TAG_NAME }} + + - name: Build and push Docker image with latest tag + uses: docker/build-push-action@v2 + with: + context: . + push: true + tags: ghcr.io/${{ github.repository_owner }}/ro-dou:latest