Skip to content

Schedule Re-Deploy Latest #76

Schedule Re-Deploy Latest

Schedule Re-Deploy Latest #76

Workflow file for this run

name: Schedule Re-Deploy Latest
permissions:
contents: write
actions: write
on:
workflow_dispatch:
schedule:
- cron: 0 */3 * * * # Adjust the schedule as needed
jobs:
find-latest-tag:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ secrets.NKDAGILITY_BOT_APP_ID }}
private-key: ${{ secrets.NKDAGILITY_BOT_CLIENTSECRET }}
- name: Authenticate GitHub CLI
run: gh auth status
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Find latest semantic version tag (PowerShell)
id: find_tag
shell: pwsh
run: |
# GitHub API URL for the latest release
$apiUrl = "https://api.github.com/repos/${{ github.repository }}/releases/latest"
# Send the API request
$response = Invoke-RestMethod -Uri $apiUrl -Headers @{ "Accept" = "application/vnd.github+json" }
# Extract release information
$latestRelease = $response | Select-Object -Property tag_name, name, published_at, body
# Output the details
Write-Host "Latest Release for ${{ github.repository }}:"
Write-Host "Tag: $($latestRelease.tag_name)"
Write-Host "Name: $($latestRelease.name)"
Write-Host "Published: $($latestRelease.published_at)"
# GitHub CLI api
# https://cli.github.com/manual/gh_api
# GitHub CLI API call
gh api `
--method POST `
-H "Accept: application/vnd.github+json" `
-H "X-GitHub-Api-Version: 2022-11-28" `
"/repos/${{ github.repository }}/actions/workflows/main.yaml/dispatches" `
-f ref=$($latestRelease.tag_name)
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}