From 668741d028de8771e9a174aea765c50fa1af52ff Mon Sep 17 00:00:00 2001 From: ztimson Date: Thu, 4 Jun 2026 08:26:05 -0400 Subject: [PATCH] Updated build --- .github/workflows/build.yml | 83 +++++++++++++++++++++++++++++++++++ .github/workflows/website.yml | 54 ----------------------- 2 files changed, 83 insertions(+), 54 deletions(-) create mode 100644 .github/workflows/build.yml delete mode 100644 .github/workflows/website.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..81aac30 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,83 @@ +name: Build Website +run-name: Build Website + +on: + push: + +jobs: + build: + name: Build NPM Project + runs-on: ubuntu-latest + container: node + steps: + - name: Clone Repository + uses: ztimson/actions/clone@develop + + - name: Install Dependencies + run: npm i + + - name: Build Project + run: npm run build + + - name: Upload Artifacts + if: ${{inputs.artifacts}} != "false" + uses: actions/upload-artifact@v3 + with: + name: website + path: dist + retention-days: 7 + + tag: + name: Tag Version + needs: build + runs-on: ubuntu-latest + container: node + steps: + - name: Clone Repository + uses: ztimson/actions/clone@develop + + - name: Get Version Number + run: echo "VERSION=$(cat package.json | grep version | grep -Eo ':.+' | grep -Eo '[[:alnum:]\.\/\-]+')" >> $GITHUB_ENV + + - name: Tag Version + uses: ztimson/actions/tag@develop + with: + tag: ${{env.VERSION}} + + container: + name: Build Container + runs-on: ubuntu-latest + container: docker + steps: + - name: Build Container + run: | + git clone -b "${{github.ref_name}}" "$(echo ${{github.server_url}}/${{github.repository}}.git | sed s%://%://${{github.token}}@% )" . + DOCKER_HUB=$([ -n "${{secrets.DOCKER_HUB_USER}}" ] && [ -n "${{secrets.DOCKER_HUB_TOKEN}}" ] && [ -n "${{secrets.DOCKER_HUB_IMAGE}}" ] && echo "true" || echo "false") + REGISTRY="$(echo "${{github.server_url}}" | sed -E 's|https?://||')" + VERSION=$(cat package.json | grep version | grep -Eo '[0-9][[:alnum:]\.\/\-]+') + + docker login -u "${{github.repository_owner}}" -p "${{secrets.DEPLOY_TOKEN}}" "$REGISTRY" + if [ "$DOCKER_HUB" = "true" ]; then docker login -u "${{secrets.DOCKER_HUB_USER}}" -p "${{secrets.DOCKER_HUB_TOKEN}}" docker.io; fi + + docker build -t "$REGISTRY/${{github.repository}}:${{github.ref_name}}" . + docker push "$REGISTRY/${{github.repository}}:${{github.ref_name}}" + if [ "$DOCKER_HUB" = "true" ]; then + docker tag "$REGISTRY/${{github.repository}}:${{github.ref_name}}" "docker.io/${{secrets.DOCKER_HUB_IMAGE}}:${{github.ref_name}}" + docker push "docker.io/${{secrets.DOCKER_HUB_IMAGE}}:${{github.ref_name}}" + fi + + if [ "${{github.ref_name}}" = "master" ]; then + docker tag "$REGISTRY/${{github.repository}}:${{github.ref_name}}" "$REGISTRY/${{github.repository}}:$VERSION" + docker push "$REGISTRY/${{github.repository}}:$VERSION" + if [ "$DOCKER_HUB" = "true" ]; then + docker tag "$REGISTRY/${{github.repository}}:${{github.ref_name}}" "docker.io/${{secrets.DOCKER_HUB_IMAGE}}:$VERSION" + docker push "docker.io/${{secrets.DOCKER_HUB_IMAGE}}:$VERSION" + fi + + docker tag "$REGISTRY/${{github.repository}}:${{github.ref_name}}" "$REGISTRY/${{github.repository}}:latest" + docker push "$REGISTRY/${{github.repository}}:latest" + if [ "$DOCKER_HUB" = "true" ]; then + docker tag "$REGISTRY/${{github.repository}}:${{github.ref_name}}" "docker.io/${{secrets.DOCKER_HUB_IMAGE}}:latest" + docker push "docker.io/${{secrets.DOCKER_HUB_IMAGE}}:latest" + fi + fi diff --git a/.github/workflows/website.yml b/.github/workflows/website.yml deleted file mode 100644 index a66525d..0000000 --- a/.github/workflows/website.yml +++ /dev/null @@ -1,54 +0,0 @@ -name: Build Website -run-name: Build Website - -on: - push: - -jobs: - build: - name: Build NPM Project - runs-on: ubuntu-latest - container: node - steps: - - name: Clone Repository - uses: ztimson/actions/clone@develop - - - name: Install Dependencies - run: npm i - - - name: Build Project - run: npm run build - - - name: Upload Artifacts - if: ${{inputs.artifacts}} != "false" - uses: actions/upload-artifact@v3 - with: - name: website - path: dist - retention-days: 7 - - tag: - name: Tag Version - needs: build - runs-on: ubuntu-latest - container: node - steps: - - name: Clone Repository - uses: ztimson/actions/clone@develop - - - name: Get Version Number - run: echo "VERSION=$(cat package.json | grep version | grep -Eo ':.+' | grep -Eo '[[:alnum:]\.\/\-]+')" >> $GITHUB_ENV - - - name: Tag Version - uses: ztimson/actions/tag@develop - with: - tag: ${{env.VERSION}} - - publish: - name: Build & Push Dockerfile - needs: build - uses: ztimson/actions/.github/workflows/docker.yaml@develop - with: - name: ztimson/legio-30 - repository: ${{github.server_url}}/${{github.repository}}.git - pass: ${{secrets.DEPLOY_TOKEN}}