not private #37
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: 'Build and Publish Docker Image' | |
on: | |
push: | |
branches: | |
- 'fix/*' | |
jobs: | |
publish-to-npm: | |
name: Publish to NPM | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
permissions: | |
id-token: write | |
contents: read | |
packages: write | |
env: | |
NPM_CONFIG_PROVENANCE: true | |
outputs: | |
release: ${{ steps.set-release.outputs.release }} | |
steps: | |
- name: Checkout | |
uses: actions/[email protected] | |
with: | |
fetch-depth: 0 | |
- name: Debug Publish Branch | |
run: echo "${{ github.event.pull_request.base.ref }}" | |
- run: corepack enable | |
- uses: actions/[email protected] | |
with: | |
node-version: 20.x | |
cache: 'pnpm' | |
- run: pnpm install --frozen-lockfile | |
- name: Set release version in env | |
run: echo "RELEASE=$(node -e 'console.log(require("./package.json").version)')" >> $GITHUB_ENV | |
- name: Build | |
run: pnpm build | |
- name: Cache build artifacts | |
uses: actions/cache/[email protected] | |
with: | |
path: ./packages/**/dist | |
key: ${{ github.sha }}-release:build | |
- name: Dry-run publishing | |
run: pnpm publish -r --no-git-checks --dry-run | |
- name: Publish to NPM | |
run: | | |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc | |
node .github/scripts/trim-fe-packageJson.js | |
node .github/scripts/ensure-provenance-fields.mjs | |
sed -i "s/default: 'dev'/default: 'stable'/g" packages/cli/dist/config/schema.js | |
pnpm publish -r --publish-branch ${{github.event.pull_request.base.ref}} --access public --tag rc --no-git-checks | |
- id: set-release | |
run: echo "release=${{ env.RELEASE }}" >> $GITHUB_OUTPUT | |
build-and-push: | |
needs: [publish-to-npm] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/[email protected] | |
with: | |
fetch-depth: 0 | |
- name: Set up Docker Buildx | |
uses: docker/[email protected] | |
- name: Login to Docker Hub | |
uses: docker/[email protected] | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
- name: Build and Push Docker Image | |
uses: docker/[email protected] | |
with: | |
context: ./docker/images/n8n | |
build-args: | | |
N8N_VERSION=${{ needs.publish-to-npm.outputs.release }} | |
platforms: linux/amd64,linux/arm64 | |
provenance: false | |
push: true | |
tags: | | |
${{ secrets.DOCKERHUB_USERNAME }}/n8n:${{ needs.publish-to-npm.outputs.release }} | |
docker.io/${{ github.repository_owner }}/n8n:${{ needs.publish-to-npm.outputs.release }} | |