diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4fd2e6c..4d012d7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,10 +5,16 @@ on: pull_request: branches: [main] +env: + IMAGE_NAME: ${{ github.repository }} + REGISTRY: ghcr.io + jobs: test: name: 'Test' runs-on: ubuntu-latest + permissions: + contents: read steps: - name: Checkout uses: actions/checkout@v3 @@ -31,6 +37,8 @@ jobs: build: name: 'Build' runs-on: ubuntu-latest + permissions: + contents: read steps: - name: Checkout uses: actions/checkout@v3 @@ -50,11 +58,49 @@ jobs: - name: Build run: yarn build + docker: + name: 'Docker publish' + needs: [test, build] + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Log into registry ${{ env.REGISTRY }} + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + uses: docker/build-push-action@v3 + with: + push: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + platforms: linux/amd64,linux/arm64 + deploy-demo: name: Deploy demo site if: github.event_name == 'push' && github.ref == 'refs/heads/main' needs: [test, build] runs-on: ubuntu-latest + permissions: + contents: read + pages: write steps: - name: Checkout uses: actions/checkout@v3 diff --git a/.nvmrc b/.nvmrc index 3c03207..209e3ef 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -18 +20 diff --git a/Dockerfile b/Dockerfile index 9e125f4..1f94f73 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:14-alpine as builder +FROM --platform=${BUILDPLATFORM} node:20-alpine as builder ARG DEFAULT_HOMESERVER @@ -13,6 +13,6 @@ COPY tsconfig.json webpack.config.js webpack.parts.js ./ ENV DEFAULT_HOMESERVER ${DEFAULT_HOMESERVER} RUN yarn build -FROM nginxinc/nginx-unprivileged:1.21-alpine +FROM --platform=${TARGETPLATFORM} nginxinc/nginx-unprivileged:1-alpine COPY --from=builder /files-sdk-demo/dist /usr/share/nginx/html