Add API publishing to GitHub Container Registry workflow
Updated workflow to publish API Docker image to GitHub Container Registry.
This commit is contained in:
parent
04a0358dd6
commit
85fc8b4024
92
.github/workflows/ghcr-publish.yml
vendored
92
.github/workflows/ghcr-publish.yml
vendored
@ -1,55 +1,37 @@
|
|||||||
name: Publish to GitHub Container Registry
|
name: Publish API to GitHub Container Registry
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
tags:
|
|
||||||
- 'v*'
|
jobs:
|
||||||
pull_request:
|
build-and-push-api:
|
||||||
branches:
|
runs-on: ubuntu-latest
|
||||||
- main
|
# This permission is necessary to allow the workflow to write to GitHub Packages.
|
||||||
|
permissions:
|
||||||
env:
|
contents: read
|
||||||
REGISTRY: ghcr.io
|
packages: write
|
||||||
IMAGE_NAME: ${{ github.repository }}
|
|
||||||
|
steps:
|
||||||
jobs:
|
- name: Checkout code
|
||||||
build-and-push:
|
uses: actions/checkout@v3
|
||||||
runs-on: ubuntu-latest
|
|
||||||
permissions:
|
- name: Log in to GitHub Container Registry
|
||||||
contents: read
|
uses: docker/login-action@v2
|
||||||
packages: write
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
steps:
|
username: ${{ github.actor }}
|
||||||
- name: Checkout repository
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
- name: Set up Docker Buildx
|
uses: docker/setup-buildx-action@v2
|
||||||
uses: docker/setup-buildx-action@v3
|
|
||||||
|
- name: Build and push Docker image
|
||||||
- name: Log in to Container Registry
|
uses: docker/build-push-action@v4
|
||||||
uses: docker/login-action@v3
|
with:
|
||||||
with:
|
# This tells Docker where to find your Dockerfile and code
|
||||||
registry: ${{ env.REGISTRY }}
|
context: ./apps/api
|
||||||
username: ${{ github.actor }}
|
push: true
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
# This will tag the image with both 'latest' and 'main'
|
||||||
|
tags: ghcr.io/${{ github.repository }}:latest,ghcr.io/${{ github.repository }}:main
|
||||||
- name: Extract metadata
|
|
||||||
id: meta
|
|
||||||
uses: docker/metadata-action@v5
|
|
||||||
with:
|
|
||||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
|
||||||
tags: |
|
|
||||||
type=ref,event=branch
|
|
||||||
type=semver,pattern={{version}}
|
|
||||||
type=semver,pattern={{major}}.{{minor}}
|
|
||||||
type=sha
|
|
||||||
|
|
||||||
- name: Build and push Docker image
|
|
||||||
uses: docker/build-push-action@v5
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
push: ${{ github.event_name != 'pull_request' }}
|
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user