Skip to content

Update Summary endpoints #1671

Update Summary endpoints

Update Summary endpoints #1671

Workflow file for this run

name: Update clients PRs
on:
# Trigger the workflow on pull requests targeting the main branch
pull_request:
types: [assigned, unassigned, opened, reopened, synchronize, edited, labeled, unlabeled, edited, closed]
branches:
- main
jobs:
get_available_profiles:
runs-on: ubuntu-latest
outputs:
profiles: ${{ steps.get-profiles-step.outputs.profiles }}
steps:
- uses: actions/checkout@v2
- id: get-profiles-step
uses: ./.github/actions/get-profiles
update_client_pr:
if: github.event.action != 'closed'
runs-on: ubuntu-latest
needs: [ get_available_profiles ]
strategy:
fail-fast: false
matrix:
profile: ${{ fromJson(needs.get_available_profiles.outputs.profiles) }}
env:
CLIENT_PATH: generated-clients/${{ matrix.profile.name }}
CLIENT_REPOSITORY: ${{ github.repository_owner }}/${{ matrix.profile.repository }}
steps:
- name: Check out repository code
uses: actions/checkout@v2
- name: Set up JDK 8
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'adopt'
- name: Cache openapi-generator dependencies and build
uses: actions/cache@v2
with:
path: |
~/.m2/repository
${{ env.GITHUB_WORKSPACE }}/apivideo-generator/target
key: ${{ runner.os }}-build-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-build-
- name: Checkout client repository
uses: actions/checkout@v2
with:
repository: ${{ env.CLIENT_REPOSITORY }}
token: ${{ secrets.PAT }}
path: ${{ env.CLIENT_PATH }}
- name: Remove files to allow files deletion from git
run: |
cd ${{ env.CLIENT_PATH }}
shopt -s extglob
rm -Rf !(.git|examples|.|..)
- name: Generate client
run: mvn package -P ${{ matrix.profile.name }}
# Make changes to pull request here
- uses: peter-evans/create-pull-request@v3
id: cpr
with:
token: ${{ secrets.PAT }}
path: ${{ env.CLIENT_PATH }}
commit-message: ${{ github.event.pull_request.title }}
committer: GitHub <noreply@github.com>
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
branch: ${{ github.event.pull_request.head.ref }}
title: ${{ github.event.pull_request.title }}
body: |
> ${{ github.event.pull_request.body }}
> Created by @${{ github.actor }} via ${{ github.event.pull_request.html_url }}
delete-branch: true
labels: ${{ join(github.event.pull_request.labels.*.name) }}
assignees: ${{ join(github.event.pull_request.assignees.*.login) }}
# reviewers: ${{ join(github.event.pull_request.requested_reviewers.*.login) }} #TODO
# draft: true
- name: Check tests results
uses: apivideo/api.video-pull-checks-conclusion-action@v1.0.0
if: ${{ steps.cpr.outputs.pull-request-head-sha }}
with:
token: ${{ secrets.PAT }}
repo: ${{ matrix.profile.repository }}
owner: ${{ github.repository_owner }}
sha: ${{ steps.cpr.outputs.pull-request-head-sha }}
generate_documentation:
if: github.event.action != 'closed'
runs-on: ubuntu-latest
needs: [update_client_pr]
steps:
- name: Check out repository code
uses: actions/checkout@v2
- name: Checkout client repository
uses: actions/checkout@v2
with:
repository: ${{ github.repository_owner }}/api.video-documentation
token: ${{ secrets.PAT }}
path: generated-clients/documentation
- name: Copy oas_apivideo.yaml
run: |
cp -R oas_apivideo.yaml generated-clients/documentation/openapi.yaml
- uses: peter-evans/create-pull-request@v3
id: cpr
with:
token: ${{ secrets.PAT }}
path: generated-clients/documentation
commit-message: ${{ github.event.pull_request.title }}
committer: GitHub <noreply@github.com>
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
branch: ${{ github.event.pull_request.head.ref }}
title: ${{ github.event.pull_request.title }}
body: |
> ${{ github.event.pull_request.body }}
> Created by @${{ github.actor }} via ${{ github.event.pull_request.html_url }}
delete-branch: true
labels: ${{ join(github.event.pull_request.labels.*.name) }}
assignees: ${{ join(github.event.pull_request.assignees.*.login) }}
merge_client_pr:
# this job will only run if the PR has been merged
if: github.event.action == 'closed' && github.event.pull_request.merged == true
runs-on: ubuntu-latest
needs: [ get_available_profiles ]
strategy:
matrix:
profile:
- ${{ fromJson(needs.get_available_profiles.outputs.profiles) }}
- name: documentation
repository: api.video-documentation
env:
CLIENT_REPOSITORY: ${{ github.repository_owner }}/${{ matrix.profile.repository }}
steps:
- run: |
echo PR ${{ github.event.repo.name }}#${{ github.event.number }} has been merged
- name: Look for existing PRs and merge them
id: commit
uses: actions/github-script@v3
with:
github-token: ${{ secrets.PAT }}
script: |
const { data: pullRequests } = await github.request(`GET /repos/${process.env.CLIENT_REPOSITORY}/pulls`, { head: context.payload.pull_request.head.label });
if (pullRequests.length > 0) {
pullRequests.forEach(async (pullRequest) => {
console.log(`Found ${pullRequest.state} PR ${process.env.CLIENT_REPOSITORY}#${pullRequest.number}`);
const mergeResponse = await github.request(`PUT /repos/${process.env.CLIENT_REPOSITORY}/pulls/${pullRequest.number}/merge`);
console.log('mergeResponse', mergeResponse);
});
} else {
console.log(`There are no PRs from branch ${context.payload.pull_request.head.ref} on ${process.env.CLIENT_REPOSITORY} repository.`);
}
close_client_pr:
# this job will only run if the PR has been closed without being merged
if: github.event.action == 'closed' && github.event.pull_request.merged == false
runs-on: ubuntu-latest
needs: [ get_available_profiles ]
strategy:
matrix:
profile:
- ${{ fromJson(needs.get_available_profiles.outputs.profiles) }}
- name: documentation
repository: api.video-documentation
env:
CLIENT_REPOSITORY: ${{ github.repository_owner }}/${{ matrix.profile.repository }}
steps:
- run: |
echo PR ${{ github.event.repo.name }}#${{ github.event.number }} has been closed
- name: Look for existing PRs and close them
id: commit
uses: actions/github-script@v3
with:
github-token: ${{ secrets.PAT }}
script: |
const { data: pullRequests } = await github.request(`GET /repos/${process.env.CLIENT_REPOSITORY}/pulls`, { head: context.payload.pull_request.head.label });
if (pullRequests.length > 0) {
pullRequests.forEach(async (pullRequest) => {
console.log(`Found ${pullRequest.state} PR ${process.env.CLIENT_REPOSITORY}#${pullRequest.number}`);
await github.request(`PATCH /repos/${process.env.CLIENT_REPOSITORY}/pulls/${pullRequest.number}`, { state: 'closed' });
});
} else {
console.log(`There are no PRs from branch ${context.payload.pull_request.head.ref} on ${process.env.CLIENT_REPOSITORY} repository.`);
}
for f of *; do
case $f in
*-clients)
print $f
;;
esac
done