-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #61 from Informatik-Projekt-Kurs/bencodes07-patch-1
Create netlify-status-update.yml
- Loading branch information
Showing
1 changed file
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
name: Update Netlify Deployment Status | ||
|
||
on: | ||
push: | ||
branches: | ||
- main # Adjust this to the branch you are deploying from | ||
workflow_dispatch: | ||
|
||
jobs: | ||
update-deployment-status: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Get Netlify deployment status | ||
id: get-status | ||
run: | | ||
NETLIFY_SITE_ID="your_netlify_site_id" | ||
NETLIFY_TOKEN="your_netlify_token" | ||
response=$(curl -s -H "Authorization: Bearer $NETLIFY_TOKEN" "https://api.netlify.com/api/v1/sites/$NETLIFY_SITE_ID/deploys") | ||
latest_deploy=$(echo $response | jq -r '.[0]') | ||
deploy_status=$(echo $latest_deploy | jq -r '.state') | ||
deploy_url=$(echo $latest_deploy | jq -r '.deploy_url') | ||
echo "Deploy status: $deploy_status" | ||
echo "Deploy URL: $deploy_url" | ||
echo "::set-output name=status::$deploy_status" | ||
echo "::set-output name=url::$deploy_url" | ||
env: | ||
NETLIFY_TOKEN: ${{ secrets.NETLIFY_TOKEN }} | ||
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} | ||
|
||
- name: Set GitHub deployment status | ||
uses: octokit/[email protected] | ||
with: | ||
route: POST /repos/${{ github.repository }}/deployments | ||
mediaType: '{"previews":["ant-man"]}' | ||
deployment: | | ||
{ | ||
"ref": "${{ github.sha }}", | ||
"environment": "production", | ||
"description": "Netlify deployment", | ||
"required_contexts": [] | ||
} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Set deployment status | ||
uses: octokit/[email protected] | ||
with: | ||
route: POST /repos/${{ github.repository }}/deployments/${{ steps.get-status.outputs.status }}/statuses | ||
mediaType: '{"previews":["flash"]}' | ||
status: | | ||
{ | ||
"state": "${{ steps.get-status.outputs.status == 'ready' && 'success' || 'failure' }}", | ||
"target_url": "${{ steps.get-status.outputs.url }}", | ||
"description": "Netlify deployment status" | ||
} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |