From b8775ae7ad84736213289650b60e15b15788bca8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mija=C3=ADl=20Rond=C3=B3n?= Date: Wed, 15 Jan 2025 10:25:02 -0500 Subject: [PATCH] ci(docker): publish on public registry (#56) --- .github/workflows/main.yml | 35 +++++---------------- .github/workflows/publish-docker.yaml | 45 +++++++++++++++++++++++++++ .github/workflows/publish.yml | 45 ++++++++++----------------- 3 files changed, 69 insertions(+), 56 deletions(-) create mode 100644 .github/workflows/publish-docker.yaml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 60e88ae..80ceccb 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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 }} diff --git a/.github/workflows/publish-docker.yaml b/.github/workflows/publish-docker.yaml new file mode 100644 index 0000000..3d92ab8 --- /dev/null +++ b/.github/workflows/publish-docker.yaml @@ -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 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 3ff488d..2605491 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -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: @@ -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 }}