Skip to content

Build and Push Mainline Nginx Distroless Docker Image #7

Build and Push Mainline Nginx Distroless Docker Image

Build and Push Mainline Nginx Distroless Docker Image #7

name: Build and Push Mainline Nginx Distroless Docker Image
on:
schedule:
- cron: '0 3 * * *'
pull_request:
branches:
- main
push:
branches:
- main
jobs:
build:
runs-on: self-hosted
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Build Docker image (no push)
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile-mainline
load: true
tags: distrolessdevops/nginx-distroless:latest
push:
runs-on: self-hosted
needs: build
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
steps:
- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Push Docker image
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile-mainline
push: true
tags: distrolessdevops/nginx-distroless:latest
- name: Logout from Docker Hub
run: docker logout