Skip to content

Commit 08a623d

Browse files
committed
ci(cd): fix invalid job-level if; move secret/PR checks into steps for deploy job
1 parent 27e0bfc commit 08a623d

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

.github/workflows/cd.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ jobs:
8484
deploy-compose:
8585
runs-on: ubuntu-latest
8686
needs: build-and-push
87-
if: ${{ secrets.SSH_HOST != '' && secrets.SSH_USER != '' && secrets.SSH_PRIVATE_KEY != '' && (github.event_name != 'pull_request_target' || github.event.pull_request.head.repo.full_name == github.repository) }}
8887
environment: production
8988
concurrency:
9089
group: prod-deploy
@@ -101,6 +100,21 @@ jobs:
101100
with:
102101
ref: ${{ env.REF }}
103102

103+
- name: Verify required secrets are present
104+
env:
105+
SSH_HOST: ${{ secrets.SSH_HOST }}
106+
SSH_USER: ${{ secrets.SSH_USER }}
107+
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
108+
run: |
109+
for v in SSH_HOST SSH_USER SSH_PRIVATE_KEY; do
110+
if [ -z "${!v}" ]; then echo "Missing secret: $v"; exit 1; fi
111+
done
112+
- name: Verify PR origin (internal only)
113+
if: ${{ github.event_name == 'pull_request_target' }}
114+
run: |
115+
if [ "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }}" ]; then
116+
echo "Refusing to deploy from external fork PR"; exit 1; fi
117+
104118
- name: Upload docker-compose file
105119
uses: appleboy/scp-action@v0.1.7
106120
with:

0 commit comments

Comments
 (0)