Skip to content

Commit

Permalink
create workflow to publish prod image to ghcr
Browse files Browse the repository at this point in the history
  • Loading branch information
fugal-dy committed Nov 8, 2023
1 parent a407ef0 commit 707aae9
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/ghcr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Container image

on:
release:
types: [created]

# Run build for any PRs - we won't push in those however
pull_request:
branches:
- main

# Publish `main` as Docker `dev` image.
push:
branches:
- main

concurrency:
group: build-${{ github.ref }}
cancel-in-progress: true

env:
IMAGE_NAME: projectcaluma/s3-hooked
REGISTRY: ghcr.io

jobs:
# Push image to GitHub Packages.
# See also https://docs.docker.com/build/ci/github-actions/
container-registry:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read

steps:
- uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Log in to the Container registry
uses: docker/login-action@v2
if: github.event_name != 'pull_request'
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=dev,enable={{is_default_branch}}
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
target: prod
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

0 comments on commit 707aae9

Please sign in to comment.