diff --git a/.github/workflows/backend-ci.yml b/.github/workflows/backend-ci.yml deleted file mode 100644 index 77bed59..0000000 --- a/.github/workflows/backend-ci.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: Backend CI - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -jobs: - build: - runs-on: ubuntu-latest - - defaults: - run: - working-directory: ./backend - - steps: - - uses: actions/checkout@v3 - - - name: Use Node.js 22 - uses: actions/setup-node@v3 - with: - node-version: 22 - - - name: Install dependencies - run: npm install - - - name: Check types - run: npm run type-check - - - name: Build Express app - run: npm run build diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..ec916ca --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,39 @@ +name: ci + +on: + push: + branches: + - master + - renovate/* + pull_request: + branches: + - master + +jobs: + api-ci: + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./backend + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v3 + with: + node-version: 22 + - run: npm ci + - run: npm run type-check + - run: npm run build + ui-ci: + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./frontend + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v3 + with: + node-version: 16 + - run: npm install + - run: npm run lint + - run: npm run type-check + - run: npm run build \ No newline at end of file diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..005ad93 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,74 @@ +name: Docker +on: + push: + branches: + - "master" + +jobs: + build: + name: "Build (${{ matrix.component }})" + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + strategy: + fail-fast: true + matrix: + component: [backend, frontend] + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + with: + platforms: arm64 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Log into registry ${{ env.REGISTRY }} + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GH_TOKEN }} + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: ${{ matrix.component }} + push: ${{ github.event_name != 'pull_request' }} + platforms: linux/amd64 + file: ${{ matrix.component }}/Dockerfile + tags: | + ghcr.io/csesoc/website-${{ matrix.component }}:${{ github.sha }} + ghcr.io/csesoc/website-${{ matrix.component }}:latest + labels: ${{ steps.meta.outputs.labels }} + deploy-prod: + name: Deploy Production (CD) + runs-on: ubuntu-latest + needs: [build] + concurrency: prod + environment: + name: prod + if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' }} + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + repository: csesoc/deployment + token: ${{ secrets.GH_TOKEN }} + ref: develop + - name: Install yq - portable yaml processor + uses: mikefarah/yq@v4.27.2 + - name: Update deployment + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + run: | + git config user.name "CSESoc CD" + git config user.email "technical@csesoc.org.au" + git checkout -b update/website-prod/${{ github.sha }} + yq -i '.items[0].spec.template.spec.containers[0].image = "ghcr.io/csesoc/website-backend:${{ github.sha }}"' apps/projects/website/prod/deploy-backend.yml + yq -i '.items[0].spec.template.spec.containers[0].image = "ghcr.io/csesoc/website-frontend:${{ github.sha }}"' apps/projects/website/prod/deploy-frontend.yml + git add . + git commit -m "feat(website/prod): update image" + git push -u origin update/website-prod/${{ github.sha }} + gh pr create -B develop --title "feat(website/prod): update image" --body "Updates the image for the website-prod deployment to commit csesoc/csesoc-website@${{ github.sha }}." > URL + gh pr merge $(cat URL) --squash -d \ No newline at end of file diff --git a/.github/workflows/frontend-ci.yml b/.github/workflows/frontend-ci.yml deleted file mode 100644 index 1afed18..0000000 --- a/.github/workflows/frontend-ci.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: Frontend CI - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -jobs: - build: - runs-on: ubuntu-latest - - defaults: - run: - working-directory: ./frontend - - steps: - - uses: actions/checkout@v3 - - - name: Use Node.js 16 - uses: actions/setup-node@v3 - with: - node-version: 16 - - - name: Install dependencies - run: npm install - - - name: Lint code - run: npm run lint - - - name: Check types - run: npm run type-check - - - name: Build Next.js app - run: npm run build