feat: fixes ci

This commit is contained in:
2025-10-31 23:05:45 -03:00
parent d971be653d
commit a6cffbf567
4 changed files with 24 additions and 93 deletions

View File

@@ -2,8 +2,6 @@ name: ci
on:
push:
branches:
- "main"
jobs:
build:
@@ -11,7 +9,7 @@ jobs:
strategy:
matrix:
node-version: [18.x]
node-version: [22.12.0]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
@@ -27,35 +25,28 @@ jobs:
docker:
needs: [build]
runs-on: ubuntu-latest
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop')
env:
IMAGE_TAG: ${{ github.ref_name == 'main' && 'latest' || 'dev' }}
IMAGE_NAME: ghcr.io/${{ github.repository_owner }}/frontend-hideyoshi.com:latest
permissions:
contents: read
packages: write # required to push to ghcr.io
id-token: write # optional for OIDC if you use it
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
- name: Log in to GHCR
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v2
with:
platforms: linux/amd64,linux/arm64
push: true
tags: yoshiunfriendly/frontend-hideyoshi.com:latest
- name: Build image
run: docker build -t $IMAGE_NAME .
run-dispatcher:
needs: docker
runs-on: ubuntu-latest
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Runs Infra-Hideyoshi.com Deployment Dispatcher
run: |
curl -X POST https://api.github.com/repos/HideyoshiSolutions/infra-hideyoshi.com/dispatches \
-H 'Accept: application/vnd.github.everest-preview+json' \
-u ${{ secrets.ACTIONS_KEY }} \
--data '{"event_type": "refresh-deployments", "client_payload": { "deployments": "frontend-deployment" }}'
- name: Push image
run: docker push $IMAGE_NAME

View File

@@ -1,27 +0,0 @@
name: vercel-cleanup-pr
on:
pull_request:
types: [closed]
env:
VERCEL_CLI_TOKEN: ${{ secrets.VERCEL_CLI_TOKEN }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
GITHUB_PR_ID: ${{ github.event.number }}
jobs:
cleanup:
runs-on: ubuntu-latest
steps:
- name: Cleanup Vercel Deployments
run: |
closed_deployments=$(curl "https://api.vercel.com/v6/deployments?projectId=$VERCEL_PROJECT_ID" \
-H "Accept: application/json" \
-H "Authorization: Bearer ${VERCEL_CLI_TOKEN}" | jq -r ".deployments[] | select(.meta.githubPrId == \"${GITHUB_PR_ID}\") | .uid")
for deployment in $closed_deployments; do
echo "Deleting Deployment: $deployment"
curl "https://api.vercel.com/v6/now/deployments/$deployment" \
-X DELETE \
-H "Authorization: Bearer ${VERCEL_CLI_TOKEN}"
done

View File

@@ -1,33 +0,0 @@
name: vercel-cleanup-preview
on:
push:
branches:
- '*'
- '!main'
- '!devel'
env:
VERCEL_CLI_TOKEN: ${{ secrets.VERCEL_CLI_TOKEN }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
GIT_PREVIOS_COMMIT: ${{ github.event.before }}
jobs:
cleanup:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Cleanup Vercel Deployments
run: |
invalid_deployments=$(curl "https://api.vercel.com/v6/deployments?projectId=$VERCEL_PROJECT_ID" \
-H "Accept: application/json" \
-H "Authorization: Bearer ${VERCEL_CLI_TOKEN}" | jq -r ".deployments[] | select(.meta.githubCommitSha == \"${GIT_PREVIOS_COMMIT}\") | .uid")
for deployment in $invalid_deployments; do
echo "Deleting Deployment: $deployment"
curl "https://api.vercel.com/v6/now/deployments/$deployment" \
-X DELETE \
-H "Authorization: Bearer ${VERCEL_CLI_TOKEN}"
done