Skip to content

Commit

Permalink
added build pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
michealch committed Jan 31, 2024
1 parent efd33bb commit 9e9fdd0
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Build and Push Docker Image

on:
schedule:
# Runs at 00:00 UTC every Sunday
- cron: '0 0 * * 0'
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
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
push: true
tags: distrolessdevops/nginx-distroless:latest

- name: Logout from Docker Hub
if: always()
run: docker logout

0 comments on commit 9e9fdd0

Please sign in to comment.