-
-
Notifications
You must be signed in to change notification settings - Fork 58
63 lines (60 loc) · 2.17 KB
/
Copy pathdocker-standalone.yml
File metadata and controls
63 lines (60 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
name: Publish standalone Docker image
on:
workflow_run:
workflows: ["Publish to npm"]
types: [completed]
branches: [master]
jobs:
check:
if: github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
permissions:
packages: read
outputs:
should_publish: ${{ steps.check.outputs.should_publish }}
version: ${{ steps.check.outputs.version }}
is_prerelease: ${{ steps.check.outputs.is_prerelease }}
steps:
- uses: actions/checkout@v5
- name: Check if image already published
id: check
run: |
VERSION=$(node -p "require('./package.json').version")
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
if [[ "$VERSION" == *-* ]]; then
echo "is_prerelease=true" >> "$GITHUB_OUTPUT"
else
echo "is_prerelease=false" >> "$GITHUB_OUTPUT"
fi
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
if docker manifest inspect "ghcr.io/${{ github.repository }}/standalone:$VERSION" > /dev/null 2>&1; then
echo "should_publish=false" >> "$GITHUB_OUTPUT"
echo "Image $VERSION already exists, skipping."
else
echo "should_publish=true" >> "$GITHUB_OUTPUT"
echo "New version detected: $VERSION"
fi
publish:
needs: check
if: needs.check.outputs.should_publish == 'true'
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v5
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: docker-standalone/Dockerfile
push: true
tags: |
ghcr.io/${{ github.repository }}/standalone:${{ needs.check.outputs.version }}
${{ needs.check.outputs.is_prerelease == 'false' && format('ghcr.io/{0}/standalone:latest', github.repository) || '' }}