Skip to content

Commit

Permalink
ci(docker): publish on public registry (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
mijailr authored Jan 15, 2025
1 parent fcda08e commit b8775ae
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 56 deletions.
35 changes: 7 additions & 28 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,17 @@ on:

permissions:
contents: read
id-token: write
packages: write

jobs:
build:
publish-docker:
uses: ./.github/workflows/publish-docker.yml

trigger-build:
runs-on: ubuntu-latest
needs:
- publish-docker
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
cache: npm
cache-dependency-path: package-lock.json
node-version: 20

- name: Installing Dependencies
run: npm install

- name: Lint
run: npm run lint -ws

- name: Build
run: npm run build -ws

- name: Publish Image
uses: littlehorse-enterprises/publish-image@v1
with:
image-name: lh-sso-workflow-bridge-ui
registry: ecr
dockerfile: Dockerfile

- name: Trigger Build Standalone
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT_USER_TASKS }}
Expand Down
45 changes: 45 additions & 0 deletions .github/workflows/publish-docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: publish-docker
run-name: Publish Docker Images
on:
workflow_call:
inputs:
tag:
type: string
required: false
default: ''
permissions:
packages: write
contents: read

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
cache: npm
cache-dependency-path: package-lock.json
node-version: 20

- name: Installing Dependencies
run: npm install

- name: Lint
run: npm run lint -ws

- name: Build
run: npm run build -ws

- name: Publish Image
uses: littlehorse-enterprises/publish-image@v1
with:
image-name: lh-sso-workflow-bridge-ui
dockerfile: Dockerfile
github-token: ${{ secrets.GITHUB_TOKEN }}
tags: |
type=semver,pattern={{version}}
type=ref,event=branch
45 changes: 17 additions & 28 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,19 @@ on:

permissions:
contents: read
id-token: write
packages: write

jobs:
prepare:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.set_tag.outputs.tag }}
steps:
- name: Set Tag
id: set_tag
run: |
echo "tag=$(echo $GITHUB_REF | sed -n 's/refs\/tags\/v//p')" >> $GITHUB_OUTPUT
publish-npm:
runs-on: ubuntu-latest
steps:
Expand All @@ -27,31 +37,10 @@ jobs:
run: npm publish -w api-client --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
publish-docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
cache: npm
cache-dependency-path: package-lock.json
node-version: 20

- name: Installing Dependencies
run: npm install

- name: Lint
run: npm run lint -ws

- name: Build
run: npm run build -ws

- name: Publish Image
uses: littlehorse-enterprises/publish-image@v1
with:
image-name: lh-sso-workflow-bridge-ui
registry: ecr
dockerfile: Dockerfile
publish-docker:
uses: ./.github/workflows/publish-docker.yml
needs:
- prepare
with:
tag: ${{ needs.prepare.outputs.tag }}

0 comments on commit b8775ae

Please sign in to comment.