Skip to content

Commit

Permalink
Merge pull request #61 from Informatik-Projekt-Kurs/bencodes07-patch-1
Browse files Browse the repository at this point in the history
Create netlify-status-update.yml
  • Loading branch information
bencodes07 authored Jun 16, 2024
2 parents cb59bbb + 9c3066a commit 39477c8
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/netlify-status-update.yml
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 }}

0 comments on commit 39477c8

Please sign in to comment.