From e69a2956651a19a94a42b2c80d4f2ff35fafda9e Mon Sep 17 00:00:00 2001 From: Rico Herwig Date: Tue, 7 Nov 2023 19:56:09 +0100 Subject: [PATCH] wip: add actions for build and push --- .editorconfig | 3 ++ .github/workflows/docker-create-image.yaml | 62 ++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 .github/workflows/docker-create-image.yaml diff --git a/.editorconfig b/.editorconfig index aab2e41..4a5d1de 100644 --- a/.editorconfig +++ b/.editorconfig @@ -12,3 +12,6 @@ max_line_length = 100 [*.md] max_line_length = off trim_trailing_whitespace = false + +[*.yaml] +indent_size = 2 diff --git a/.github/workflows/docker-create-image.yaml b/.github/workflows/docker-create-image.yaml new file mode 100644 index 0000000..841e7de --- /dev/null +++ b/.github/workflows/docker-create-image.yaml @@ -0,0 +1,62 @@ +name: Docker Create Image + +on: + push: + branches: + - 'main' + release: + types: [ published ] + +jobs: + build-and-push: + name: Build and push Docker image + runs-on: ubuntu-latest + steps: + - name: Check out the repository + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: 20 + + - uses: pnpm/action-setup@v2 + name: Install pnpm + with: + version: 8 + run_install: false + + - name: Cache .pnpm-store + uses: actions/cache@v3 + with: + path: ~/.pnpm-store + key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm- + + - name: Install Dependencies + run: pnpm install + + - name: Build + run: pnpm build + + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: rherwig/hrwg-website + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: ./apps/website/Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }}