-
Notifications
You must be signed in to change notification settings - Fork 0
62 lines (51 loc) · 1.89 KB
/
shedule.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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 }}