Skip to content

Commit 7f17586

Browse files
committed
Use Docker meta
1 parent 30fa51b commit 7f17586

2 files changed

Lines changed: 12 additions & 11 deletions

File tree

.github/workflows/publish.yml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,23 +59,26 @@ jobs:
5959
steps:
6060
- name: Checkout
6161
uses: actions/checkout@v3
62-
- name: Get version
63-
uses: actions/github-script@v6
64-
id: version
62+
- name: Docker meta
63+
id: meta
64+
uses: docker/metadata-action@v4
6565
with:
66-
result-encoding: string
67-
script: return context.ref.split('/')[2].substring(1)
66+
images: |
67+
ghcr.io/${{ github.repository }}
68+
tags: |
69+
type=semver,pattern={{version}}
70+
type=semver,pattern={{major}}.{{minor}}
71+
type=semver,pattern={{major}}
6872
- name: Setup Docker
6973
uses: ./.github/actions/setup-docker
7074
with:
7175
registry_domain: ghcr.io
7276
registry_username: ${{ secrets.GH_USER }}
7377
registry_password: ${{ secrets.GH_TOKEN }}
74-
- name: Build and push ${{ github.repository }}:${{ steps.version.outputs.result }}
78+
- name: Build and push
7579
uses: docker/build-push-action@v3
7680
with:
7781
push: true
7882
platforms: linux/amd64,linux/arm64
79-
tags: |
80-
ghcr.io/${{ github.repository }}:latest
81-
ghcr.io/${{ github.repository }}:${{ steps.version.outputs.result }}
83+
tags: ${{ steps.meta.outputs.tags }}
84+
labels: ${{ steps.meta.outputs.labels }}

Dockerfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,3 @@ ENTRYPOINT ["node"]
3939
CMD ["server.js"]
4040

4141
USER node
42-
43-
LABEL org.opencontainers.image.source https://github.com/makenew/nodejs-server

0 commit comments

Comments
 (0)