diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 8a10807..3e411ea 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -2,16 +2,36 @@ name: Build and publish a Docker image to ghcr.io on: release: types: [ published ] - push: - branches: [ master ] jobs: docker_publish: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Build and publish a Docker image for ${{ github.repository }} - uses: macbre/push-to-ghcr@master + - name: 'Checkout GitHub Action' + uses: actions/checkout@main + + - name: Docker meta + id: meta + uses: docker/metadata-action@v4 + with: + images: ghcr.io/thedatabaseme/hello-world + flavor: latest=true + tags: | + type=semver,pattern={{version}} + + - name: Login to image repository + if: github.ref_type == 'tag' + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v3 with: - image_name: ${{ github.repository }} - github_token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + context: . + file: Dockerfile + push: ${{ github.ref_type == 'tag' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file