Skip to content

Commit

Permalink
Try running test in container and push container image to registry
Browse files Browse the repository at this point in the history
  • Loading branch information
ahwayakchih authored Jan 16, 2025
1 parent 5989eb9 commit 389c73d
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions .github/workflows/puppeteer-container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ name: puppeteer-container
on:
push:
branches: [ "puppeteer-container" ]
tags: [ v* ]

jobs:

build:
runs-on: ubuntu-latest

env:
IMAGE_NAME: puppeteer-container
steps:
- name: Workaround Windows mess and set git to keep original line endings
run: git config --global core.autocrlf false
Expand All @@ -18,7 +20,33 @@ jobs:
- run: podman --version

- name: Build container image
run: podman build -t puppeteer -f puppeteer.containerfile
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: |
podman run --rm --init -v $(pwd):/app -w /app --userns=keep-id -it $IMAGE_NAME:latest npm install
podman run --rm --init -v $(pwd):/app -w /app --userns=keep-id -it $IMAGE_NAME:latest npm run puppeteer
podman run --rm --init -v $(pwd):/app -w /app --userns=keep-id -it $IMAGE_NAME:latest 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

0 comments on commit 389c73d

Please sign in to comment.