|
68 | 68 | with: |
69 | 69 | context: ./${{ matrix.component }} |
70 | 70 | file: ./${{ matrix.component }}/Dockerfile |
71 | | - push: true |
| 71 | + # Only push if it's a push to main OR a PR from the same repo (not a fork) |
| 72 | + # External contributors from forks can't write to the org's container registry |
| 73 | + push: ${{ github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository }} |
72 | 74 | tags: ${{ steps.meta.outputs.tags }} |
73 | 75 | labels: ${{ steps.meta.outputs.labels }} |
74 | 76 | platforms: linux/amd64,linux/arm64 |
@@ -122,9 +124,66 @@ jobs: |
122 | 124 | PR_NUMBER: ${{ github.event.number }} |
123 | 125 | REPO_OWNER: ${{ github.repository_owner }} |
124 | 126 | VALUES_CONTENT: ${{ steps.values.outputs.values }} |
| 127 | + IS_FORK: ${{ github.event.pull_request.head.repo.full_name != github.repository }} |
125 | 128 | run: | |
126 | 129 | # yamllint disable rule:line-length |
127 | | - cat > instructions.md << EOF |
| 130 | + if [ "${IS_FORK}" = "true" ]; then |
| 131 | + cat > instructions.md << EOF |
| 132 | + ## 🚀 Preview Build Complete! |
| 133 | +
|
| 134 | + Your pull request has been built successfully. However, since this is from a fork, preview images cannot be pushed to the organization's container registry. |
| 135 | +
|
| 136 | + ### Testing Your Changes |
| 137 | +
|
| 138 | + To test your changes, you can build and deploy locally: |
| 139 | +
|
| 140 | + \`\`\`bash |
| 141 | + # Clone this PR |
| 142 | + git fetch origin pull/${PR_NUMBER}/head:pr-${PR_NUMBER} |
| 143 | + git checkout pr-${PR_NUMBER} |
| 144 | +
|
| 145 | + # Build and deploy locally |
| 146 | + ./build-and-deploy.sh |
| 147 | +
|
| 148 | + # Or for minikube |
| 149 | + ./build-and-deploy-minikube.sh |
| 150 | +
|
| 151 | + # Port forward to access locally |
| 152 | + kubectl port-forward service/wrongsecrets-balancer 3000:3000 |
| 153 | + \`\`\` |
| 154 | +
|
| 155 | + ### Alternative: Manual Build |
| 156 | +
|
| 157 | + \`\`\`bash |
| 158 | + # Build images locally |
| 159 | + cd wrongsecrets-balancer |
| 160 | + docker build -t my-wrongsecrets-balancer:test . |
| 161 | + cd ../cleaner |
| 162 | + docker build -t my-cleaner:test . |
| 163 | +
|
| 164 | + # Deploy with custom images using Helm |
| 165 | + helm repo add wrongsecrets https://owasp.org/wrongsecrets-ctf-party |
| 166 | + helm repo update |
| 167 | +
|
| 168 | + helm install my-preview wrongsecrets/wrongsecrets-ctf-party \\ |
| 169 | + --set balancer.repository=my-wrongsecrets-balancer \\ |
| 170 | + --set balancer.tag=test \\ |
| 171 | + --set wrongsecretsCleanup.repository=my-cleaner \\ |
| 172 | + --set wrongsecretsCleanup.tag=test \\ |
| 173 | + --set balancer.imagePullPolicy=Never \\ |
| 174 | + --set wrongsecretsCleanup.imagePullPolicy=Never |
| 175 | + \`\`\` |
| 176 | +
|
| 177 | + ### Why Can't Images Be Pushed? |
| 178 | +
|
| 179 | + External contributors don't have write permissions to the organization's GitHub Container Registry. This is a security measure to protect the organization's packages. |
| 180 | +
|
| 181 | + --- |
| 182 | +
|
| 183 | + *This preview was automatically generated for PR #${PR_NUMBER}* |
| 184 | + EOF |
| 185 | + else |
| 186 | + cat > instructions.md << EOF |
128 | 187 | ## 🚀 Preview Deployment Ready! |
129 | 188 |
|
130 | 189 | Your pull request has been built and is ready for preview deployment. |
@@ -198,6 +257,7 @@ jobs: |
198 | 257 |
|
199 | 258 | *This preview was automatically generated for PR #${PR_NUMBER}* |
200 | 259 | EOF |
| 260 | + fi |
201 | 261 | # yamllint enable rule:line-length |
202 | 262 |
|
203 | 263 | echo "content<<EOF" >> $GITHUB_OUTPUT |
|
0 commit comments