This repository has been archived by the owner on Nov 10, 2024. It is now read-only.
Docker Image Push (on commit and base image update) #82
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: Docker Image Push (on commit and base image update) | |
on: | |
push: | |
branches: [ "master" ] | |
schedule: | |
- cron: "15 4 */3 * *" | |
env: | |
IMAGE_OWNER: kimbtechnologies | |
IMAGE_NAME: wbo | |
BASE_IMAGE: library/node:20-alpine | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
# Init and check | |
- name: Access to repository contents | |
uses: actions/checkout@v3 | |
- name: Check for new baseimage | |
id: check | |
uses: lucacome/docker-image-update-checker@v1 | |
with: | |
base-image: "${{env.BASE_IMAGE}}" | |
image: "${{env.IMAGE_OWNER}}/${{env.IMAGE_NAME}}:latest" | |
if: github.event_name != 'push' | |
# Build image | |
- name: Build the Docker image | |
run: docker build . --file "Dockerfile" --tag "$IMAGE_OWNER/$IMAGE_NAME:latest" | |
if: ${{ (github.event_name == 'push') || (steps.check.outputs.needs-updating == 'true') }} | |
# Push latest tag | |
- name: Login to DockerHub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_TOKEN }} | |
if: ${{ (github.event_name == 'push') || (steps.check.outputs.needs-updating == 'true') }} | |
- name: Push to DockerHub | |
run: docker push "$IMAGE_OWNER/$IMAGE_NAME:latest" | |
if: ${{ (github.event_name == 'push') || (steps.check.outputs.needs-updating == 'true') }} |