Skip to content

Commit

Permalink
Refactor Docker image publishing workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
yacosta738 committed Dec 25, 2023
1 parent 2ba5b05 commit 2a7ee2e
Showing 1 changed file with 21 additions and 27 deletions.
48 changes: 21 additions & 27 deletions .github/workflows/deploy-container-image.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,25 @@
name: Deploy container image to GitHub Packages
name: Publish Docker image

on:
# Trigger the workflow every time you push to the `main` branch
# Using a different branch name? Replace `main` with your branch’s name
push:
branches: [ main ]
# Allows you to run this workflow manually from the Actions tab on GitHub.
workflow_dispatch:

# Allow this job to clone the repo and create a page deployment
permissions:
contents: read
pages: write
id-token: write
release:
types: [published]

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

jobs:
build:
name: Push Docker image to multiple registries
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Checkout your repository using git
uses: actions/checkout@v4

- name: Install Tools & Dependencies
uses: ./.github/actions/install

Expand All @@ -41,23 +35,23 @@ jobs:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: |
n4t5u/${{ env.IMAGE_NAME }}
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
images: |
n4t5u/${{ env.IMAGE_NAME }}
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build the container image
run: pnpm run build # build:docker

- name: Build and push Docker image
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

0 comments on commit 2a7ee2e

Please sign in to comment.