Schedule Re-Deploy Latest #73
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
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 }} |