ci: also test with Node.js 22.x #107
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build Dockerfile | |
on: push | |
jobs: | |
build: | |
runs-on: ubuntu-22.04 | |
steps: | |
# Checks-out the repository under $GITHUB_WORKSPACE. | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Build Dockerfile | |
run: docker build . -t plotly | |
- name: Start Docker container | |
run: | | |
CONTAINER_ID=$(docker run --rm -d -p 3000:3000 --net=host plotly) | |
while ! netstat -tna | grep LISTEN | grep --silent 3000 | |
do | |
echo Waiting for Node.js server to start ... | |
sleep 5 | |
done | |
netstat -tulpen | |
docker logs "$CONTAINER_ID" | |
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" }' | |
echo -e "\nStopping container ..." | |
docker stop -t 1 "$CONTAINER_ID" | |
- name: Push Docker image (versioned tag) to registry | |
run: | | |
VERSION=$(git describe --always) | |
echo Version is $VERSION. | |
if [[ "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]] | |
then | |
echo "Version seems to be a new tag." | |
else | |
echo "Version is not a new tag, exiting here." | |
exit 0 | |
fi | |
TAG=$(echo "$VERSION" | cut --characters=2- ) | |
IMAGE_NAME=ghcr.io/${{ github.repository_owner }}/plotly-node-export-server/plotly-node-export-server:$TAG | |
docker tag plotly "$IMAGE_NAME" | |
TAG_MAJOR=$(echo "$TAG" | cut -d. -f1) | |
IMAGE_NAME_MAJOR=ghcr.io/${{ github.repository_owner }}/plotly-node-export-server/plotly-node-export-server:$TAG_MAJOR | |
docker tag plotly "$IMAGE_NAME_MAJOR" | |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | |
docker push "$IMAGE_NAME" | |
docker push "$IMAGE_NAME_MAJOR" | |
docker logout ghcr.io |