Template
fix(ci): guard check/build/deploy against unsubstituted template (#6)
This commit is contained in:
+21
-4
@@ -11,8 +11,25 @@ env:
|
|||||||
IMAGE: __PROJECT_NAME__
|
IMAGE: __PROJECT_NAME__
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
guard:
|
||||||
|
name: Detect unsubstituted template
|
||||||
|
runs-on: self-hosted
|
||||||
|
outputs:
|
||||||
|
is_template: ${{ steps.detect.outputs.is_template }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- id: detect
|
||||||
|
run: |
|
||||||
|
if grep -q '__MODULE_PATH__' go.mod; then
|
||||||
|
echo "is_template=true" >> "$GITHUB_OUTPUT"
|
||||||
|
else
|
||||||
|
echo "is_template=false" >> "$GITHUB_OUTPUT"
|
||||||
|
fi
|
||||||
|
|
||||||
check:
|
check:
|
||||||
name: Lint / Test / Vet
|
name: Lint / Test / Vet
|
||||||
|
needs: guard
|
||||||
|
if: needs.guard.outputs.is_template != 'true'
|
||||||
runs-on: self-hosted
|
runs-on: self-hosted
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
@@ -34,9 +51,9 @@ jobs:
|
|||||||
|
|
||||||
build:
|
build:
|
||||||
name: Build & Import
|
name: Build & Import
|
||||||
needs: check
|
needs: [guard, check]
|
||||||
|
if: needs.guard.outputs.is_template != 'true' && github.event_name != 'pull_request'
|
||||||
runs-on: self-hosted
|
runs-on: self-hosted
|
||||||
if: github.event_name != 'pull_request'
|
|
||||||
outputs:
|
outputs:
|
||||||
image-tag: ${{ steps.meta.outputs.sha-tag }}
|
image-tag: ${{ steps.meta.outputs.sha-tag }}
|
||||||
steps:
|
steps:
|
||||||
@@ -63,9 +80,9 @@ jobs:
|
|||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
name: Deploy via GitOps
|
name: Deploy via GitOps
|
||||||
needs: build
|
needs: [guard, build]
|
||||||
|
if: needs.guard.outputs.is_template != 'true' && github.ref == 'refs/heads/main' && github.event_name == 'push'
|
||||||
runs-on: self-hosted
|
runs-on: self-hosted
|
||||||
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
|
|
||||||
steps:
|
steps:
|
||||||
- name: Update image tag in infra repo
|
- name: Update image tag in infra repo
|
||||||
env:
|
env:
|
||||||
|
|||||||
Reference in New Issue
Block a user