From 13626642c9e1b48d6b7c5d440c8329627cc0fb93 Mon Sep 17 00:00:00 2001 From: Lucid Date: Fri, 5 Dec 2025 17:58:09 -0500 Subject: [PATCH] update ci/cd --- .github/workflows/main.yml | 80 +++++++++++++----------- .github/workflows/vercel-preview.yaml | 44 ------------- .github/workflows/vercel-production.yaml | 42 ------------- 3 files changed, 45 insertions(+), 121 deletions(-) delete mode 100644 .github/workflows/vercel-preview.yaml delete mode 100644 .github/workflows/vercel-production.yaml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4a4984f..7b8a2aa 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,24 +1,22 @@ -# This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions - -name: Node.js CI +name: Main on: - # Trigger the workflow on push or pull request, push: - branches: [main, stable] + branches: [main] pull_request: - # These types of PRs - types: [opened, synchronize, reopened] + branches: [main] + +env: + REGISTRY: gitea.lucids-cove.duckdns.org + OWNER: wkc + IMAGE_NAME: no-twitter-bot-stats jobs: - build: + build-and-push-docker-image: runs-on: ubuntu-24.04 - strategy: matrix: - node-version: [20.x, 22.x] - # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + node-version: [20.x] steps: - name: "Base requirements" run: | @@ -27,27 +25,39 @@ jobs: # ansible collections ansible-galaxy collection install community.general --force ansible-galaxy collection install ansible.posix --force - - uses: actions/checkout@v4 - - # Corepack - - name: Install Corepack - run: npm install -g corepack - - name: "Enable Corepack" - run: corepack enable - - name: "Install Yarn" - run: corepack prepare yarn@latest --activate - - # YARN - - name: "Install Dependencies" - run: yarn install # will run `yarn install` command - #- uses: borales/actions-yarn@v3.0.0 - # with: - # cmd: test # will run `yarn test` command - #- uses: borales/actions-yarn@v3.0.0 - # with: - # cmd: type-check # will run `yarn type-check` command - - name: "Lint Repo" - run: yarn lint # will run `yarn lint` command - - name: "Build Code" - run: yarn run build # will run `yarn build` command + - name: Enable Corepack + run: npm install -g corepack && corepack enable + - name: Log into registry ${{ env.REGISTRY }} + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ env.OWNER }} + password: ${{ secrets.TOKEN }} + - name: Docker Hub Login + run: echo "${{ secrets.DOCKER_HUB_TOKEN }}" | docker login -u "${{ secrets.DOCKER_HUB_USERNAME }}" --password-stdin + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Setup Docker buildx + uses: docker/setup-buildx-action@v2 + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.IMAGE_NAME }} + - name: Build and Push Versioned Docker Image + id: build-and-push + uses: docker/build-push-action@v4 + if: ${{ github.ref != 'refs/heads/main' }} + with: + context: . + push: ${{ !github.event.pull_request.head.repo.fork }} + tags: ${{ steps.meta.outputs.tags }} + - name: Build and Push Latest Docker Image + id: build-and-push-latest + uses: docker/build-push-action@v4 + if: ${{ github.ref == 'refs/heads/main' }} + with: + context: . + push: true + tags: ${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.IMAGE_NAME }}:latest diff --git a/.github/workflows/vercel-preview.yaml b/.github/workflows/vercel-preview.yaml deleted file mode 100644 index da6226c..0000000 --- a/.github/workflows/vercel-preview.yaml +++ /dev/null @@ -1,44 +0,0 @@ -name: Vercel Preview Deployment -env: - VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} - VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} -on: - # Trigger the workflow on push or pull request, - # push: - # branches: [main, stable] - pull_request: - # These types of PRs - types: [opened, synchronize, reopened] -jobs: - Deploy-Preview: - runs-on: ubuntu-24.04 - steps: - # Setup environment - - name: "Base requirements" - run: | - # packages - apk update && apk add --no-cache git docker docker-compose nodejs gpg openssh npm ansible - # ansible collections - ansible-galaxy collection install community.general --force - ansible-galaxy collection install ansible.posix --force - - - uses: actions/checkout@v2 - - # Corepack - - name: Install Corepack - run: npm install -g corepack - - name: "Enable Corepack" - run: corepack enable - - name: "Install Yarn" - run: corepack prepare yarn@latest --activate - - # Vercel - - uses: actions/checkout@v2 - - name: "Install Vercel CLI" - run: npm install --global vercel@latest - - name: "Pull Vercel Environment Information" - run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }} - - name: "Build Project Artifacts" - run: vercel build --token=${{ secrets.VERCEL_TOKEN }} - - name: "Deploy Project Artifacts to Vercel" - run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }} diff --git a/.github/workflows/vercel-production.yaml b/.github/workflows/vercel-production.yaml deleted file mode 100644 index d7801a7..0000000 --- a/.github/workflows/vercel-production.yaml +++ /dev/null @@ -1,42 +0,0 @@ -name: Vercel Production Deployment -env: - VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} - VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} -on: - push: - branches: - - main - - stable -jobs: - Deploy-Production: - runs-on: ubuntu-24.04 - - steps: - # Setup environment - - name: "Base requirements" - run: | - # packages - apk update && apk add --no-cache git docker docker-compose nodejs gpg openssh npm ansible - # ansible collections - ansible-galaxy collection install community.general --force - ansible-galaxy collection install ansible.posix --force - - - uses: actions/checkout@v2 - - # Corepack - - name: Install Corepack - run: npm install -g corepack - - name: "Enable Corepack" - run: corepack enable - - name: "Install Yarn" - run: corepack prepare yarn@latest --activate - - # Vercel - - name: "Install Vercel CLI" - run: npm install --global vercel@latest - - name: "Pull Vercel Environment Information" - run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }} - - name: "Build Project Artifacts" - run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }} - - name: "Deploy Project Artifacts to Vercel" - run: vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }}