Merge pull request #83 from HideyoshiSolutions/feature/better-ci-workflow

feat: fixes ci
This commit is contained in:
2025-10-31 23:12:13 -03:00
committed by GitHub
4 changed files with 24 additions and 93 deletions

View File

@@ -2,8 +2,6 @@ name: ci
on: on:
push: push:
branches:
- "main"
jobs: jobs:
build: build:
@@ -11,7 +9,7 @@ jobs:
strategy: strategy:
matrix: matrix:
node-version: [18.x] node-version: [22.12.0]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/ # See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps: steps:
@@ -27,35 +25,28 @@ jobs:
docker: docker:
needs: [build] needs: [build]
runs-on: ubuntu-latest 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: steps:
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v1 uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx - name: Log in to GHCR
uses: docker/setup-buildx-action@v1 uses: docker/login-action@v3
- name: Login to DockerHub
uses: docker/login-action@v1
with: with:
username: ${{ secrets.DOCKERHUB_USERNAME }} registry: ghcr.io
password: ${{ secrets.DOCKERHUB_TOKEN }} username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push - name: Build image
uses: docker/build-push-action@v2 run: docker build -t $IMAGE_NAME .
with:
platforms: linux/amd64,linux/arm64
push: true
tags: yoshiunfriendly/frontend-hideyoshi.com:latest
run-dispatcher: - name: Push image
needs: docker run: docker push $IMAGE_NAME
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" }}'

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

View File

@@ -50,13 +50,13 @@
"budgets": [ "budgets": [
{ {
"type": "initial", "type": "initial",
"maximumWarning": "1mb", "maximumWarning": "2.5mb",
"maximumError": "1.5mb" "maximumError": "5mb"
}, },
{ {
"type": "anyComponentStyle", "type": "anyComponentStyle",
"maximumWarning": "2.5kb", "maximumWarning": "5kb",
"maximumError": "5kb" "maximumError": "10kb"
} }
], ],
"fileReplacements": [ "fileReplacements": [
@@ -66,7 +66,7 @@
} }
], ],
"outputHashing": "all", "outputHashing": "all",
"serviceWorker": true "serviceWorker": "ngsw-config.json"
}, },
"development": { "development": {
"optimization": false, "optimization": false,
@@ -96,7 +96,7 @@
} }
}, },
"test": { "test": {
"builder": "@angular/build:karma", "builder": "@angular/build:application",
"options": { "options": {
"main": "src/test.ts", "main": "src/test.ts",
"polyfills": "src/polyfills.ts", "polyfills": "src/polyfills.ts",