Skip to content

Commit

Permalink
Merge pull request #11 from EresDevOrg/main
Browse files Browse the repository at this point in the history
fix: prevent deploy to production on open PR
  • Loading branch information
0x4007 authored Apr 4, 2024
2 parents a9c65fe + 415f2e4 commit 5454d2d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,13 @@ runs:
const items = response.data.items
if (items.length < 1) {
console.error('No PRs found')
return
return {forcePreviewDeploy: false, pullRequestNumber: null }
}
const pullRequestNumber = items[0].number
const forcePreviewDeploy = pullRequestNumber > 0 && items[0].pull_request.merged_at == null
console.info("Pull request number is", pullRequestNumber)
return pullRequestNumber
console.info("forcePreviewDeploy", forcePreviewDeploy)
return {forcePreviewDeploy: forcePreviewDeploy, pullRequestNumber: pullRequestNumber }
- name: Download build artifact
uses: dawidd6/action-download-artifact@v3
Expand All @@ -64,7 +66,7 @@ runs:
run_id: ${{ inputs.workflow_run_id }}

- name: Deploy to Cloudflare
run: bash ../../_actions/ubiquity/cloudflare-deploy-action/main/.github/cloudflare-deploy.sh "${{ inputs.repository }}" "${{ inputs.production_branch }}" "${{ inputs.output_directory }}" "${{ inputs.current_branch }}"
run: bash ../../_actions/ubiquity/cloudflare-deploy-action/main/.github/cloudflare-deploy.sh "${{ inputs.repository }}" "${{ inputs.production_branch }}" "${{ inputs.output_directory }}" "${{ fromJSON(steps.pr.outputs.result).forcePreviewDeploy && format('{0}/{1}', github.repository_owner, inputs.current_branch) || inputs.current_branch }}"
shell: bash
env:
CLOUDFLARE_ACCOUNT_ID: ${{ inputs.cloudflare_account_id }}
Expand All @@ -78,5 +80,5 @@ runs:
yarn tsx src/index.ts \
--deployment_output "${{ env.DEPLOYMENT_OUTPUT }}" \
--repository "${{ inputs.repository }}" \
--pull_request_number "${{ steps.pr.outputs.result }}" \
--pull_request_number "${{ fromJSON(steps.pr.outputs.result).pullRequestNumber }}" \
--commit_sha "${{ inputs.commit_sha }}"

0 comments on commit 5454d2d

Please sign in to comment.