-
Notifications
You must be signed in to change notification settings - Fork 157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: Support GitHub deployments #274
Comments
adding: environment: <environment_name> works for me here, is it what you are looking for ? |
My understanding is that this is for choosing which Cloudflare Pages environment to deploy to, not the GitHub environment for deployments. |
I have the same problem, the pages-action did set the proper url for preview/release deployments. With wrangler-actions I could for release deployment hardcode it but how do I set the url when deploying preview? |
I would love to have this as well. And also the preview aliases are not set to the git branch for preview branches. It would be great to have them back =) |
What output exactly is needed to support GitHub Deployments? Does the deployment-url output work for previews? |
@nprogers ideally I'd love to have the same functionality as the CF-Pages+GitHub interfation provides via a bot leaving a comment with all the required information if this is not possible, then at least the gh api to be triggered to show the deployment environment with the preview URL as the current pages-action does: |
When you do implement this, please don't make users pass in the GitHub token manually (cloudflare/pages-action#69). Actions can always access Also please keep bot comments separate from deployments. I do not want a bot leaving a comment on our PRs! I only want the deployments. |
I'm using the below as a workaround (basically grab the on: [push]
...
- name: Publish to Cloudflare Pages
id: deploy
uses: cloudflare/[email protected]
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ vars.CLOUDFLARE_ACCOUNT_ID }}
command: pages deploy . --project-name=${{ vars.CLOUDFLARE_PROJECT_NAME }} --commit-dirty=true
- uses: actions/github-script@v7
with:
script: |
const issue_number = (await github.rest.repos.listPullRequestsAssociatedWithCommit({
commit_sha: context.sha,
owner: context.repo.owner,
repo: context.repo.repo,
})
).data[0].number;
github.rest.issues.createComment({
issue_number: issue_number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '🚢 deployed to <${{ steps.deploy.outputs.deployment-url }}>'
})
EDIT: Probably pretty easy to use the |
To build on what @dijitali shared, here's how we're creating deployments now while using this action. I posted this in cloudflare/pages-action#117 (comment) but it's a lot more relevant here! The job steps below assume you already have a steps:
# Do stuff
- name: Create GitHub deployment
id: github_deployment
env:
GH_TOKEN: "${{ github.token }}"
run: |
id=$(gh api "repos/{owner}/{repo}/deployments" \
-f "ref=${{ github.ref_name }}" \
-F "auto_merge=false" \
-F "required_contexts[]" \
-f "environment=${{ matrix.name }} (${{ github.ref_name == 'main' && 'production' || 'preview' }})" \
-F "production_environment=${{ github.ref_name == 'main' && 'true' || 'false' }}" \
-q ".id"
)
echo "id=${id?}" >> "$GITHUB_OUTPUT"
# Do stuff
- name: Deploy to Cloudflare Pages
id: deploy
uses: cloudflare/wrangler-action@9681c2997648301493e78cacbfb790a9f19c833f # v3.9.0
with:
accountId: "${{ vars.CLOUDFLARE_ACCOUNT_ID }}"
apiToken: "${{ secrets.CLOUDFLARE_API_TOKEN }}"
command: pages deploy
workingDirectory: "${{ matrix.directory }}"
# Do stuff
- name: Create GitHub deployment status
if: always() && steps.github_deployment.outcome == 'success'
env:
GH_TOKEN: "${{ github.token }}"
run: |
gh api "repos/{owner}/{repo}/deployments/${{ steps.github_deployment.outputs.id }}/statuses" \
-f "state=${{ steps.deploy.outcome == 'success' && 'success' || 'failure' }}" \
-f "environment_url=${{ steps.deploy.outputs.deployment-url }}" \
-F "auto_inactive=false" |
My problem is figuring out a way to use the commit sha (eg. Ideas? Will just setting through
and then just use |
I solved it like this:
|
I'm coming from the deprecated pages-action and one feature I really miss is being able to update the GitHub deployments environment.
The text was updated successfully, but these errors were encountered: