Skip to content

v16.10.5

v16.10.5 #409

name: Publish to Docker Hub
on:
workflow_dispatch:
push:
branches:
- 'main'
release:
types: [published]
pull_request:
branches:
- 'main'
jobs:
check_secrets:
runs-on: ubuntu-latest
outputs:
secrets_available: ${{ steps.check.outputs.secrets_available }}
steps:
- id: check
run: |
if [[ -n "${{ secrets.DOCKERHUB_USERNAME }}" && -n "${{ secrets.DOCKERHUB_TOKEN }}" ]]; then
echo "::set-output name=secrets_available::true"
else
echo "::set-output name=secrets_available::false"
fi
shell: bash
build:
needs: check_secrets
if: ${{ needs.check_secrets.outputs.secrets_available == 'true' }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: npm install and build
run: |
npm ci
npx nx build api -c=production
- name: Archive production artifacts
uses: actions/upload-artifact@v3
with:
name: build
path: dist
if-no-files-found: error
publish:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
katsuba/nx-cloud
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Download production artifacts
uses: actions/download-artifact@v3
with:
name: build
path: dist
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: ./apps/api/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: |
linux/amd64
linux/arm64/v8