Skip to content

Commit 6f2c3f8

Browse files
committed
ci: push Docker images for versions with tag
1 parent 250c79e commit 6f2c3f8

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

.github/workflows/docker.yml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ jobs:
88
steps:
99
# Checks-out the repository under $GITHUB_WORKSPACE.
1010
- uses: actions/checkout@v4
11+
with:
12+
fetch-depth: 0
1113
- name: Build Dockerfile
1214
run: docker build . -t plotly
1315
- name: Start Docker container
@@ -23,10 +25,27 @@ jobs:
2325
curl -X POST -i 'http://[::1]:3000/' --data '{ "x": ["2013-10-04 22:23:00", "2013-11-04 22:23:00", "2013-12-04 22:23:00"], "y": [1, 3, 6], "type": "scatter" }'
2426
echo -e "\nStopping container ..."
2527
docker stop -t 1 "$CONTAINER_ID"
26-
- name: Push Docker image to registry
28+
- name: Push Docker image (edge) to registry
2729
run: |
2830
IMAGE_NAME=ghcr.io/${{ github.repository_owner }}/plotly-node-export-server/plotly-node-export-server:edge
2931
docker tag plotly "$IMAGE_NAME"
3032
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
3133
docker push "$IMAGE_NAME"
3234
docker logout ghcr.io
35+
- name: Push Docker image (versioned tag) to registry
36+
run: |
37+
VERSION=$(git describe --always)
38+
echo Version is $VERSION.
39+
if [[ "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]
40+
then
41+
echo "Version seems to be a new tag."
42+
else
43+
echo "Version is not a new tag, exiting here."
44+
exit 0
45+
fi
46+
TAG=$(echo "$VERSION" | cut --characters=2- )
47+
IMAGE_NAME=ghcr.io/${{ github.repository_owner }}/plotly-node-export-server/plotly-node-export-server:$TAG
48+
docker tag plotly "$IMAGE_NAME"
49+
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
50+
docker push "$IMAGE_NAME"
51+
docker logout ghcr.io

0 commit comments

Comments
 (0)