Skip to content

Schedule Re-Deploy Latest #13

Schedule Re-Deploy Latest

Schedule Re-Deploy Latest #13

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: |
$tags = git tag --sort=-v:refname | Where-Object { $_ -match '^v[0-9]+\.[0-9]+\.[0-9]+$' }
$latestTag = $tags | Select-Object -First 1
if (-not $latestTag) {
Write-Host "No valid semantic version tags found. Exiting."
exit 0
}
echo "latest_tag=$latestTag" | Out-File -FilePath $env:GITHUB_ENV -Append
Write-Host "Latest tag is $latestTag"
# 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=$latestTag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}