1# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
2#
3# SPDX-License-Identifier: curl
4
5name: AppVeyor Status Report
6
7'on':
8  status
9
10concurrency:
11  group: ${{ github.workflow }}-${{ github.event.sha }}-${{ github.event.target_url }}
12  cancel-in-progress: true
13
14permissions: {}
15
16jobs:
17  split:
18    runs-on: ubuntu-latest
19    if: ${{ github.event.sender.login == 'appveyor[bot]' }}
20    permissions:
21      statuses: write
22    steps:
23      - name: Create individual AppVeyor build statuses
24        if: ${{ github.event.sha && github.event.target_url }}
25        env:
26          APPVEYOR_COMMIT_SHA: ${{ github.event.sha }}
27          APPVEYOR_TARGET_URL: ${{ github.event.target_url }}
28          APPVEYOR_REPOSITORY: ${{ github.event.repository.full_name }}
29          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30        run: |
31          echo ${APPVEYOR_TARGET_URL} | sed 's/\/project\//\/api\/projects\//' | xargs -t -n1 curl -s | \
32            jq -c '.build.jobs[] | {target_url: ($target_url + "/job/" + .jobId),
33                                    context: (.name | sub("^(Environment: )?"; "AppVeyor / ")),
34                                    state: (.status | sub("queued"; "pending")
35                                                    | sub("starting"; "pending")
36                                                    | sub("running"; "pending")
37                                                    | sub("failed"; "failure")
38                                                    | sub("cancelled"; "error")),
39                                    description: .status}' \
40                --arg target_url ${APPVEYOR_TARGET_URL} | tee /dev/stderr | parallel --pipe -j 1 -N 1 \
41              gh api --silent --input - repos/${APPVEYOR_REPOSITORY}/statuses/${APPVEYOR_COMMIT_SHA}
42