ipydrawio/.github/workflows/badges.yml

50 wiersze
1.9 KiB
YAML

# make badges
# Copyright 2023 ipydrawio contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
on:
pull_request_target:
types: [opened]
permissions:
pull-requests: write
jobs:
binder:
runs-on: ubuntu-latest
steps:
- name: Add Binder/Lite PR comment
uses: actions/github-script@v6
env:
PR_HEAD_REF: ${{ github.event.pull_request.head.ref }}
PR_HEAD_USERREPO: ${{ github.event.pull_request.head.repo.full_name }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const PR_NUMBER = context.issue.number
const { PR_HEAD_REF, PR_HEAD_USERREPO } = process.env;
const RTD = `https://ipydrawio--${PR_NUMBER}.org.readthedocs.build/en/${PR_NUMBER}/_static/lab/index.html?path=Diagram%20Widget.ipynb`;
const BH = `https://mybinder.org/v2/gh/${PR_HEAD_USERREPO}/${PR_HEAD_REF}?urlpath=lab/tree/docs/Diagram%20Widget.ipynb`;
const LITE = `https://jupyterlite.rtfd.io/en/latest/_static/badge.svg`;
const BND = `https://mybinder.org/badge_logo.svg`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `Try this PR on [![RTD](${LITE})](${RTD}) :arrow_left: ReadTheDocs or Binder :arrow_right: [![Binder](${BND})](${BH})`,
});