Skip to content

Commit

Permalink
chore: container image publish (#52)
Browse files Browse the repository at this point in the history
* chore: add image pub workflow

Signed-off-by: jrhender <john.henderson@energyweb.org>

* chore(publish workflow): run on created release

Signed-off-by: jrhender <john.henderson@energyweb.org>

* docs(README): add note about publishing process

Signed-off-by: jrhender <john.henderson@energyweb.org>

---------

Signed-off-by: jrhender <john.henderson@energyweb.org>
  • Loading branch information
jrhender authored Feb 7, 2025
1 parent b4ff7b5 commit 11d2f25
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/container-image-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Build and Publish Docker Image

on:
workflow_dispatch:
release:
types:
- created

jobs:
build-and-push:
runs-on: ubuntu-latest

permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Get latest release version
id: get_version
run: |
LATEST_VERSION=$(gh release list --limit 1 --json tagName --jq '.[0].tagName')
echo "LATEST_VERSION=${LATEST_VERSION}" >> $GITHUB_ENV
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Check if package exists
id: check_package
run: |
if docker manifest inspect ghcr.io/${{ github.repository }}:${{ env.LATEST_VERSION }} > /dev/null 2>&1; then
echo "Package already exists. Aborting."
exit 1
fi
- name: Log in to GitHub Container Registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin

- name: Build Docker image
run: |
docker build -t ghcr.io/${{ github.repository }}:${{ env.LATEST_VERSION }} -f apps/vc-api/Dockerfile .
- name: Push Docker image to GitHub Packages
run: |
docker push ghcr.io/${{ github.repository }}:${{ env.LATEST_VERSION }}
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ To run tests across all apps and libraries in one command, a rush script has bee
$ rush test
```

## Release Process

Releases are done by manually creating a new release in GitHub.
Tooling like `release-please` or `release-it` could be used in the future to automate this process.

The release will trigger [a GitHub Action](/.github/workflows/container-image-publish.yml) to publish the new version to the GitHub Container Registry.

## Docs Editing

To edit the documentation, you can run the following command to start the docs server:
Expand Down

0 comments on commit 11d2f25

Please sign in to comment.