Skip to content

Commit

Permalink
Docker image publish (#24)
Browse files Browse the repository at this point in the history
* add docker publish action

* use semver tag

* use semver tag

* use semver tag

* update image name

* test string version

* test using package.json version

* update release action

* add changeset
  • Loading branch information
gladwindos committed Mar 15, 2024
1 parent 2cd47c3 commit aa83a72
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 1 deletion.
8 changes: 8 additions & 0 deletions .changeset/tough-cooks-mix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@gateweaver/cli": patch
"@gateweaver/policies": patch
"@gateweaver/server": patch
"@gateweaver/utils": patch
---

Publish packages
46 changes: 46 additions & 0 deletions .github/actions/publish-image/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Publish Server Docker Image
description: Create and publish Server Docker image
inputs:
REGISTRY:
description: The registry to push the image to
required: false
default: ghcr.io
IMAGE_NAME:
description: The name of the image to push
required: false
default: gateweaver/server

runs:
using: "composite"
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Get server package version
run: |
VERSION=$(jq -r '.version' ./packages/server/package.json)
echo "Server package version is $VERSION"
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ inputs.REGISTRY }}/${{ inputs.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}},value=${{ env.VERSION }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
7 changes: 6 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ jobs:
contents: write
issues: write
pull-requests: write
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup
uses: ./.github/actions/setup

- name: Create Release Pull Request or Publish to npm
- name: Create Release Pull Request or Publish packages to npm
id: changesets
uses: changesets/action@v1
with:
Expand All @@ -35,3 +36,7 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Publish Server Docker Image
if: steps.changesets.outputs.published == 'true'
uses: ./.github/actions/publish-image

0 comments on commit aa83a72

Please sign in to comment.