Skip to content

Commit

Permalink
Add GitHub Actions workflow to build Docker image (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
deptyped authored Jan 6, 2023
1 parent f40ed45 commit 8047769
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Main

on:
push:
branches: [main]
pull_request:
branches: [main]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-docker-image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v1
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v2
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and Push Versioned Docker Image
id: build-and-push
uses: docker/build-push-action@v2
if: ${{ github.ref != 'refs/heads/main' }}
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Build and Push Latest Docker Image
id: build-and-push-latest
uses: docker/build-push-action@v2
if: ${{ github.ref == 'refs/heads/main' }}
with:
context: .
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
labels: ${{ steps.meta.outputs.labels }}

0 comments on commit 8047769

Please sign in to comment.