fix: avoid creating package-lock #7
Workflow file for this run
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: puppeteer-container | |
on: | |
push: | |
branches: [ "puppeteer-container" ] | |
tags: [ v* ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
env: | |
IMAGE_NAME: puppeteer | |
steps: | |
- name: Workaround Windows mess and set git to keep original line endings | |
run: git config --global core.autocrlf false | |
- uses: actions/checkout@v4 | |
- run: podman --version | |
- name: Build container image | |
run: | | |
podman build -t "$IMAGE_NAME" -f puppeteer.containerfile \ | |
--label "org.opencontainers.image.source=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" \ | |
--label "org.opencontainers.image.description=Puppeteer container" \ | |
--label "org.opencontainers.image.licenses=MIT" | |
- name: List images | |
run: podman images | |
- name: Test run | |
run: | | |
echo $(pwd) | |
echo $GITHUB_WORKSPACE | |
mkdir node_modules | |
chmod 777 node_modules | |
podman run --rm --init -v $(pwd):/app -w /app --userns=keep-id $IMAGE_NAME npm install --no-save --no-package-lock | |
podman run --rm --init -v $(pwd):/app -w /app --userns=keep-id $IMAGE_NAME npm run puppeteer | |
podman run --rm --init -v $(pwd):/app -w /app --userns=keep-id $IMAGE_NAME xvfb-run npm test | |
- name: Login in to registry | |
if: success() | |
run: echo "${{ secrets.GITHUB_TOKEN }}" | podman login ghcr.io -u ${{ github.actor }} --password-stdin | |
- name: Push container image | |
if: success() | |
run: | | |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME | |
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') | |
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') | |
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') | |
[ "$VERSION" == "main" ] && VERSION=latest | |
echo IMAGE_ID=$IMAGE_ID | |
echo VERSION=$VERSION | |
podman tag $IMAGE_NAME $IMAGE_ID:$VERSION | |
podman push $IMAGE_ID:$VERSION |