Build images and push (on master branch or on schedule) #216
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 images and push (on master branch or on schedule) | |
on: | |
push: | |
branches: | |
- "**" | |
schedule: | |
- cron: '0 0 * * 0' | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
base-image-tag: [16-bullseye, 18-bullseye, 16-bookworm, 18-bookworm, 20-bookworm] | |
steps: | |
- uses: actions/checkout@master | |
- name: Determine Java version | |
id: java_version | |
run: | | |
if [[ "${{ matrix.base-image-tag }}" == *"-bullseye" ]]; then | |
echo 'version=11' >> $GITHUB_OUTPUT | |
else | |
echo 'version=17' >> $GITHUB_OUTPUT | |
fi | |
- name: Test | |
run: | | |
chmod +x runTests.sh && ./runTests.sh ${{ matrix.base-image-tag }} ${{ steps.java_version.outputs.version }} | |
- name: Build | |
run: | | |
docker build --build-arg=BASE_IMAGE_TAG=${{ matrix.base-image-tag }} --build-arg=JAVA_VERSION=${{ steps.java_version.outputs.version }} --tag ppiper/node-browsers:${{ matrix.base-image-tag }} . | |
docker tag ppiper/node-browsers:${{ matrix.base-image-tag }} ghcr.io/sap/ppiper-node-browsers:${{ matrix.base-image-tag }} | |
- name: Tag latest image | |
if: ${{ matrix.base-image-tag == '20-bookworm' }} | |
run: | | |
docker tag ppiper/node-browsers:${{ matrix.base-image-tag }} ppiper/node-browsers:latest | |
docker tag ghcr.io/sap/ppiper-node-browsers:${{ matrix.base-image-tag }} ghcr.io/sap/ppiper-node-browsers:latest | |
- name: Push | |
if: ${{ github.ref == 'refs/heads/master' }} | |
run: | | |
echo ${{ secrets.DOCKERHUB_PASSWORD }} | docker login -u ${{ secrets.DOCKERHUB_USER }} --password-stdin | |
echo "${{ secrets.CR_PAT }}" | docker login https://ghcr.io -u ${{ secrets.CR_USER }} --password-stdin | |
docker push ppiper/node-browsers:${{ matrix.base-image-tag }} | |
docker push ghcr.io/sap/ppiper-node-browsers:${{ matrix.base-image-tag }} | |
if [ "${{ matrix.base-image-tag }}" == 20-bookworm ]; then | |
docker push ppiper/node-browsers:latest | |
docker push ghcr.io/sap/ppiper-node-browsers:latest | |
fi |