916cbbc15006da9620e2b131be0ae9b9f80024a2
[platform/core/csapi/tizenfx.git] / .github / workflows / nightly-release.yml
1 name: "Nightly Release"
2
3
4 on:
5   schedule:
6     - cron: '0 15 * * *'
7   workflow_dispatch:
8
9 env:
10   TARGET_BRANCHES: 'master API10 API9'
11
12 jobs:
13   nightly:
14     runs-on: ubuntu-20.04
15     steps:
16     - uses: actions/checkout@v3
17       with:
18         fetch-depth: 0
19
20     - name: Find Branches to Release
21       id: find-targets
22       run: |
23         TARGETS=""
24         # find branches without the version tag
25         for x in $TARGET_BRANCHES; do
26           tags=$(git tag --contains origin/$x)
27           if [[ ! $tags =~ v[0-9]+\.[0-9]+\.[0-9]+ ]]; then
28             TARGETS="${TARGETS} $x"
29           fi
30         done
31         echo "targets=${TARGETS}" >> $GITHUB_OUTPUT
32
33     - name: Trigger Release
34       uses: actions/github-script@v6
35       env:
36         TARGETS: ${{ steps.find-targets.outputs.targets }}
37         WORKFLOW_NAME: 'Deploy Packages'
38       with:
39         github-token: ${{ secrets.TIZENAPI_GITHUB_TOKEN }}
40         script: |
41           var resp = await github.request('GET /repos/{owner}/{repo}/actions/workflows', {
42             owner: context.repo.owner,
43             repo: context.repo.repo
44           })
45           if (resp.status != 200) throw new Error('Failed to get workflow list.')
46           var workflow = resp.data.workflows.find(w => {
47             return w['name'] === process.env.WORKFLOW_NAME
48           })
49           if (!workflow) throw new Error('Unable to find the workflow.')
50           var targets = process.env.TARGETS.trim().split(' ')
51           targets.forEach(async target => {
52             var dispatchResp = await github.request('POST /repos/{owner}/{repo}/actions/workflows/{workflow_id}/dispatches', {
53               owner: context.repo.owner,
54               repo: context.repo.repo,
55               workflow_id: workflow.id,
56               ref: 'master',
57               inputs: { target, deploy_to_myget: 'true', deploy_to_tizen: 'true' }
58             })
59             console.log(`Event dispatch for ${target} : ${dispatchResp.status}`)
60           })