From cc33dbc10bf5f0c07768b6aa0fc6d9291f99f466 Mon Sep 17 00:00:00 2001 From: Ron Rise Date: Mon, 21 Apr 2025 11:39:43 -0400 Subject: [PATCH] fixed some minor stuff, might need some additional work. --- .github/workflows/build.yml | 142 ++++++++++++++++++++++++++++++++++++ .github/workflows/tests.yml | 63 ++++++++++++++++ 2 files changed, 205 insertions(+) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..afe163a --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,142 @@ +on: + push: + tags: + - '**' + +name: ๐Ÿ—๏ธโœจ Build Workflow + +jobs: + BuildFrontend: + name: ๐Ÿ–ผ๏ธ๐Ÿ”จ Build Frontend + runs-on: ubuntu-latest + steps: + + - name: ๐Ÿ›ก๏ธ๐Ÿ”’ Add Siteworx CA Certificates + run: | + apt update && apt install -yq ca-certificates curl + curl -Ls https://siteworxpro.com/hosted/Siteworx+Root+CA.pem -o /usr/local/share/ca-certificates/sw.crt + update-ca-certificates + + - name: ๐Ÿ“–๐Ÿ” Checkout Repository Code + uses: actions/checkout@v2 + with: + fetch-depth: 1 + + - name: ๐Ÿ”‘๐Ÿ” Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ vars.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: ๐Ÿ”‘๐Ÿ› ๏ธ Login to Siteworx Registry + uses: docker/login-action@v3 + with: + username: ${{ vars.SITEWORX_USERNAME }} + password: ${{ secrets.SITEWORX_PASSWORD }} + registry: scr.siteworxpro.com + + - name: ๐Ÿ—๏ธ๐Ÿ”ง Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: ๐Ÿณ๐Ÿ”จ Build Frontend Container + uses: docker/build-push-action@v6 + with: + build-args: | + VITE_API=https://reloading-manager.internal.siteworxpro.com/api + context: ./frontend + file: ./frontend/Dockerfile + tags: scr.siteworxpro.com/reloading-manager/frontend:${{ github.ref_name }} + push: true + + - name: ๐Ÿ“ฆโœจ Build Latest Frontend Container + uses: docker/build-push-action@v6 + with: + build-args: | + VITE_API=https://reloading-manager.internal.siteworxpro.com/api + context: ./frontend + file: ./frontend/Dockerfile + tags: scr.siteworxpro.com/reloading-manager/frontend:latest + push: true + + BuildBackend: + name: ๐Ÿ–ฅ๏ธ๐Ÿ”จ Build Backend + runs-on: ubuntu-latest + steps: + + - name: ๐Ÿ›ก๏ธ๐Ÿ”’ Add Siteworx CA Certificates + run: | + apt update && apt install -yq ca-certificates curl + curl -Ls https://siteworxpro.com/hosted/Siteworx+Root+CA.pem -o /usr/local/share/ca-certificates/sw.crt + update-ca-certificates + + - name: ๐Ÿ“–๐Ÿ” Checkout Repository Code + uses: actions/checkout@v2 + with: + fetch-depth: 1 + + - name: ๐Ÿ”‘๐Ÿ” Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ vars.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: ๐Ÿ”‘๐Ÿ› ๏ธ Login to Siteworx Registry + uses: docker/login-action@v3 + with: + username: ${{ vars.SITEWORX_USERNAME }} + password: ${{ secrets.SITEWORX_PASSWORD }} + registry: scr.siteworxpro.com + + - name: ๐Ÿ—๏ธ๐Ÿ”ง Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: ๐Ÿณ๐Ÿ”จ Build Backend Container + uses: docker/build-push-action@v6 + with: + context: ./backend + file: ./backend/Dockerfile + tags: scr.siteworxpro.com/reloading-manager/backend:${{ github.ref_name }} + push: true + + - name: ๐Ÿ“ฆโœจ Build Latest Backend Container + uses: docker/build-push-action@v6 + with: + context: ./backend + file: ./backend/Dockerfile + tags: scr.siteworxpro.com/reloading-manager/backend:latest + push: true + + Deploy: + name: ๐Ÿš€โœจ Deploy Application + runs-on: ubuntu-latest + needs: [BuildFrontend, BuildBackend] + steps: + + - name: ๐Ÿ›ก๏ธ๐Ÿ”’ Add Siteworx CA Certificates + run: | + apt update && apt install -yq ca-certificates curl + curl -Ls https://siteworxpro.com/hosted/Siteworx+Root+CA.pem -o /usr/local/share/ca-certificates/sw.crt + update-ca-certificates + + - name: ๐Ÿ“–๐Ÿ” Checkout Repository Code + uses: actions/checkout@v2 + with: + fetch-depth: 1 + + - name: ๐Ÿ“๐Ÿ”ง Update Deployment Manifest + run: | + echo "## Do not edit this file directly. It is auto-generated by the script." > argocd/deployment/deployment.yml + sed "s|__TAG__|${{ github.ref_name }}|g" argocd/template/deployment.yml >> argocd/deployment/deployment.yml + + - name: ๐Ÿ’พโœ… Commit Updated Manifest + uses: EndBug/add-and-commit@v9 + with: + new_branch: release/${{ github.ref_name }}-deploy + add: argocd/deployment/deployment.yml + author_name: "GitHub Action ๐Ÿค–" + author_email: gitia@siteworxpro.com + message: "๐Ÿ“๐Ÿ”„ Update deployment manifest with new image tags" + + - name: ๐Ÿš€โœจ Create Pull Request + id: cpr + uses: peter-evans/create-pull-request@v7 \ No newline at end of file diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..014cce6 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,63 @@ +on: + push: + branches: + - "*" + +name: ๐Ÿงชโœจ Unit Tests Workflow + +jobs: + build-javascript: + name: ๐Ÿงช๐Ÿ“œ JavaScript Tests + runs-on: ubuntu-latest + steps: + - name: ๐Ÿ›ก๏ธ๐Ÿ”’ Add Siteworx CA Certificates + run: | + apt update && apt install -yq ca-certificates curl + curl -Ls https://siteworxpro.com/hosted/Siteworx+Root+CA.pem -o /usr/local/share/ca-certificates/sw.crt + update-ca-certificates + - name: ๐Ÿ“–๐Ÿ” Checkout Repository Code + uses: actions/checkout@v2 + with: + fetch-depth: 1 + - name: โš™๏ธ๐Ÿ”ง Set up Node.js Environment + uses: actions/setup-node@v2 + with: + node-version: '22.14.0' + - name: ๐Ÿ“ฆ๐Ÿ“ฅ Install Dependencies + run: | + cd frontend + npm install + - name: โœ…๐Ÿงช Run JavaScript Tests + run: | + cd frontend + npm run build + + test-go: + env: + GOPRIVATE: 'git.siteworxpro.com' + GOPROXY: 'direct' + name: ๐Ÿ”๐Ÿน Go Tests + runs-on: ubuntu-latest + steps: + - name: ๐Ÿ›ก๏ธ๐Ÿ”’ Add Siteworx CA Certificates + run: | + apt update && apt install -yq ca-certificates curl + curl -Ls https://siteworxpro.com/hosted/Siteworx+Root+CA.pem -o /usr/local/share/ca-certificates/sw.crt + update-ca-certificates + - name: โš™๏ธ๐Ÿน Set up Go Environment + uses: actions/setup-go@v2 + with: + go-version: '1.24.0' + cache: true + - name: ๐Ÿ“–๐Ÿ” Checkout Repository Code + uses: actions/checkout@v2 + with: + fetch-depth: 1 + - name: ๐Ÿ“ฆ๐Ÿ“ฅ Install Dependencies + run: | + cd backend + go mod download + - name: โœ…๐Ÿ” Run Go Tests + run: | + cd backend + go test -v ./... -coverprofile=coverage.out \ No newline at end of file