Merge pull request #10 from Pinit-Scheduler/feat/api-버전-넘버링-적용 #8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: pinit-auth CD | |
| on: | |
| push: | |
| branches: [ "master" ] | |
| permissions: | |
| contents: read | |
| packages: write | |
| jobs: | |
| build-test-push-deploy: | |
| runs-on: [ arc-runner-set ] | |
| env: | |
| IMAGE_REPO: ghcr.io/pinit-scheduler/pinit-auth/app | |
| NAMESPACE: pinit | |
| DEPLOYMENT_NAME: pinit-auth | |
| CONTAINER_NAME: app | |
| MANIFEST_PATH: k8s/deployment.yaml | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup JDK | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: temurin | |
| java-version: "21" | |
| cache: gradle | |
| - name: Build & Test | |
| run: ./gradlew clean test build | |
| - name: Login to GHCR | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build & Push Image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| push: true | |
| tags: ${{ env.IMAGE_REPO }}:${{ github.sha }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Install kubectl (if needed) | |
| uses: azure/setup-kubectl@v4 | |
| with: | |
| version: v1.33.6 | |
| - name: Create kubeconfig from in-cluster ServiceAccount | |
| shell: bash | |
| run: | | |
| TOKEN="$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)" | |
| CA_PATH="/var/run/secrets/kubernetes.io/serviceaccount/ca.crt" | |
| cat > kubeconfig <<EOF | |
| apiVersion: v1 | |
| kind: Config | |
| clusters: | |
| - name: in-cluster | |
| cluster: | |
| server: https://kubernetes.default.svc | |
| certificate-authority: ${CA_PATH} | |
| contexts: | |
| - name: in-cluster | |
| context: | |
| cluster: in-cluster | |
| namespace: ${NAMESPACE} | |
| user: sa | |
| current-context: in-cluster | |
| users: | |
| - name: sa | |
| user: | |
| token: ${TOKEN} | |
| EOF | |
| echo "KUBECONFIG=$PWD/kubeconfig" >> $GITHUB_ENV | |
| - name: Install envsubst | |
| run: sudo apt-get update && sudo apt-get install -y gettext-base | |
| - name: Deploy (apply manifest with GITHUB_SHA substitution) | |
| shell: bash | |
| run: | | |
| command -v envsubst >/dev/null 2>&1 || (echo "envsubst not found" && exit 1) | |
| export GITHUB_SHA="${{ github.sha }}" | |
| envsubst < "${MANIFEST_PATH}" | kubectl apply -f - | |
| - name: Rollout status | |
| run: kubectl rollout status deployment/${{ env.DEPLOYMENT_NAME }} -n ${{ env.NAMESPACE }} --timeout=180s |