mirror of
https://github.com/AlessandroAcuna/Home.git
synced 2025-12-19 06:24:33 +00:00
removed github workflow
This commit is contained in:
73
.github/workflows/docker-publish.yml
vendored
73
.github/workflows/docker-publish.yml
vendored
@@ -1,73 +0,0 @@
|
||||
name: Build and Publish Docker image
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
workflow_dispatch: {}
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
id-token: write
|
||||
|
||||
jobs:
|
||||
build-publish:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
tags: |
|
||||
ghcr.io/${{ github.repository_owner }}/home:latest
|
||||
ghcr.io/${{ github.repository_owner }}/home:${{ github.sha }}
|
||||
file: Dockerfile
|
||||
|
||||
- name: Output image
|
||||
run: |
|
||||
echo "Image pushed: ghcr.io/${{ github.repository_owner }}/home:latest"
|
||||
echo "Image pushed: ghcr.io/${{ github.repository_owner }}/home:${{ github.sha }}"
|
||||
|
||||
redeploy:
|
||||
name: Redeploy target
|
||||
needs: build-publish
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check redeploy inputs
|
||||
if: ${{ secrets.REDEPLOY_URL != '' && secrets.REDEPLOY_TOKEN != '' }}
|
||||
run: |
|
||||
echo "Redeploy inputs present"
|
||||
|
||||
- name: Call redeploy endpoint
|
||||
if: ${{ secrets.REDEPLOY_URL != '' && secrets.REDEPLOY_TOKEN != '' }}
|
||||
run: |
|
||||
echo "Calling redeploy endpoint..."
|
||||
# curl --fail ritorna exit code != 0 se lo status HTTP non è 2xx
|
||||
curl --fail -s -X POST \
|
||||
-H "Authorization: Bearer ${{ secrets.REDEPLOY_TOKEN }}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"image\":\"ghcr.io/${{ github.repository_owner }}/home:${{ github.sha }}\"}" \
|
||||
"${{ secrets.REDEPLOY_URL }}"
|
||||
|
||||
- name: Skip redeploy warning
|
||||
if: ${{ secrets.REDEPLOY_URL == '' || secrets.REDEPLOY_TOKEN == '' }}
|
||||
run: |
|
||||
echo "REDEPLOY_URL or REDEPLOY_TOKEN not set; skipping redeploy step."
|
||||
36
DEPLOY.md
36
DEPLOY.md
@@ -1,36 +0,0 @@
|
||||
# Deploy del sito su Kubernetes usando l'immagine GHCR
|
||||
|
||||
1) Build e push automatico
|
||||
- La GitHub Action `.github/workflows/docker-publish.yml` builda e pusha l'immagine su `ghcr.io/<OWNER>/home:latest` quando fai push su `main`.
|
||||
|
||||
2) Aggiornare i manifest
|
||||
- Modifica `k8s/deployment.yaml` e sostituisci `OWNER` con il tuo GitHub username (o l'organization) se l'immagine è privata.
|
||||
|
||||
3) Secrets per cluster privato
|
||||
- Se l'immagine è privata, crea un secret per il pull:
|
||||
kubectl create secret docker-registry ghcr-secret --docker-server=ghcr.io --docker-username=<USERNAME> --docker-password=<PERSONAL_ACCESS_TOKEN> --docker-email=<EMAIL>
|
||||
- Poi aggiungi nello `spec.template.spec` del deployment:
|
||||
imagePullSecrets:
|
||||
- name: ghcr-secret
|
||||
|
||||
4) Deploy sul cluster
|
||||
- Assicurati di essere connesso al cluster (kubectl config use-context ...)
|
||||
- Applica i manifest:
|
||||
kubectl apply -f k8s/deployment.yaml
|
||||
kubectl apply -f k8s/service.yaml
|
||||
|
||||
5) Nota su permissions GHCR
|
||||
- Se usi `GITHUB_TOKEN` per pushare pacchetti, assicurati di abilitare il `permissions: packages: write` nelle settings del workflow e che il repository abbia Packages abilitati.
|
||||
|
||||
Se il push fallisce
|
||||
- Usa un Personal Access Token (PAT) con scope `write:packages` come secret `GHCR_PAT` e modifica lo step di login nella action per usare `password: ${{ secrets.GHCR_PAT }}` al posto di `GITHUB_TOKEN`.
|
||||
|
||||
I permessi del workflow
|
||||
- Lo YAML di esempio include:
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
id-token: write
|
||||
|
||||
Questo è sufficiente per pushare immagini private su GHCR se il repository appartiene all'utente. Per organizzazioni, potresti dover configurare permessi aggiuntivi.
|
||||
|
||||
Reference in New Issue
Block a user