Update cors #12
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: Backend Build | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| paths: | |
| - 'backend/**' | |
| - '.github/workflows/backend.yml' | |
| pull_request: | |
| branches: [ main ] | |
| paths: | |
| - 'backend/**' | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ${{ github.repository }}/backend | |
| jobs: | |
| build: | |
| name: Build Backend | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.25' | |
| - name: Cache Go modules | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cache/go-build | |
| ~/go/pkg/mod | |
| key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
| restore-keys: | | |
| ${{ runner.os }}-go- | |
| - name: Download dependencies | |
| working-directory: ./backend | |
| run: go mod download | |
| - name: Build application | |
| working-directory: ./backend | |
| run: go build -v ./cmd/main.go | |
| docker: | |
| name: Build & Push Docker Image | |
| runs-on: ubuntu-latest | |
| needs: build | |
| if: github.event_name == 'push' | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Log in to Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| tags: | | |
| type=ref,event=branch | |
| type=ref,event=pr | |
| type=semver,pattern={{version}} | |
| type=semver,pattern={{major}}.{{minor}} | |
| type=sha,prefix={{branch}}- | |
| type=raw,value=latest,enable={{is_default_branch}} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: ./backend | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: π Trigger Infrastructure Staging Deployment | |
| if: success() && github.ref == 'refs/heads/main' | |
| run: | | |
| curl -X POST \ | |
| -H "Authorization: token ${{ secrets.INFRA_REPO_TOKEN }}" \ | |
| -H "Accept: application/vnd.github.v3+json" \ | |
| https://api.github.com/repos/opskraken/nesohq-infra/dispatches \ | |
| -d '{"event_type":"deploy-staging"}' | |
| - name: π Deployment triggered | |
| if: success() && github.ref == 'refs/heads/main' | |
| run: | | |
| echo "β Backend image built and pushed successfully!" | |
| echo "π Infrastructure deployment triggered for staging environment" | |
| echo "π¦ Image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest" |