add text styling support #115
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy Pull Request | |
on: | |
issue_comment: | |
types: [created] | |
jobs: | |
deploy-check: | |
runs-on: ubuntu-latest | |
steps: | |
- name: "Check if user has write access" | |
uses: actions-cool/check-user-permission@main | |
id: checkUser | |
with: | |
require: "write" | |
- name: Acknowledge deployment request to commenter | |
if: steps.checkUser.outputs.require-result == 'true' | |
id: checkCommand | |
uses: khan/pull-request-comment-trigger@master | |
with: | |
trigger: "/deploy" | |
reaction: rocket | |
env: | |
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | |
outputs: | |
triggered: ${{ steps.checkCommand.outputs.triggered }} | |
publish-package: | |
name: Publish Package | |
runs-on: ubuntu-latest | |
needs: deploy-check | |
if: needs.deploy-check.outputs.triggered == 'true' | |
environment: | |
name: test.pypi.org | |
steps: | |
- name: Get pull request ref | |
id: get_pull_request_ref | |
uses: octokit/[email protected] | |
with: | |
route: GET /repos/:repository/pulls/:issue_id | |
repository: ${{ github.repository }} | |
issue_id: ${{ github.event.issue.number }} | |
env: | |
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | |
- name: Create deployment | |
id: create_deployment | |
uses: octokit/[email protected] | |
with: | |
route: POST /repos/:repository/deployments | |
env: | |
INPUT_REPOSITORY: ${{ github.repository }} | |
INPUT_REF: ${{ fromJson(steps.get_pull_request_ref.outputs.data).head.ref }} | |
INPUT_ENVIRONMENT: test.pypi.org | |
INPUT_AUTO_MERGE: false | |
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | |
- name: Set deployment status to in progress | |
id: start_deployment | |
uses: octokit/[email protected] | |
with: | |
route: POST /repos/:repository/deployments/:deployment/statuses | |
repository: ${{ github.repository }} | |
deployment: ${{ fromJson(steps.create_deployment.outputs.data).id }} | |
environment: test.pypi.org | |
log_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
state: in_progress | |
env: | |
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | |
- name: Checkout Code | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ fromJson(steps.get_pull_request_ref.outputs.data).head.ref }} | |
- name: Set up Python 3.11 | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.11 | |
- name: Install Poetry | |
uses: abatilo/[email protected] | |
with: | |
poetry-version: 1.5.1 | |
- name: Install dependencies | |
run: poetry install --no-dev | |
- name: Create custom version | |
id: create-custom-version | |
run: echo "::set-output name=pr_version::$(poetry version -s)a$(date +%s)" | |
- name: Set new version | |
run: poetry version ${{ steps.create-custom-version.outputs.pr_version }} | |
- name: Build package | |
run: poetry build | |
- name: Add test.pypi.org to Poetry | |
run: | | |
poetry config repositories.testpypi https://test.pypi.org/legacy/ | |
poetry config pypi-token.testpypi ${{ secrets.API_TOKEN }} | |
- name: Publish package | |
run: poetry publish -r testpypi | |
- name: Write comment in Pull Request | |
uses: peter-evans/create-or-update-comment@v1 | |
with: | |
issue-number: ${{ github.event.issue.number }} | |
body: | | |
Pull Request has been deployed on test.pypi.org: [${{ steps.create-custom-version.outputs.pr_version }}](https://test.pypi.org/project/signalbot/${{ steps.create-custom-version.outputs.pr_version }}/) :rocket: You can test the package by running | |
```bash | |
pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple signalbot==${{ steps.create-custom-version.outputs.pr_version }} | |
``` | |
- name: Set deployment status to success | |
id: successful_deployment | |
uses: octokit/[email protected] | |
with: | |
route: POST /repos/:repository/deployments/:deployment/statuses | |
repository: ${{ github.repository }} | |
deployment: ${{ fromJson(steps.create_deployment.outputs.data).id }} | |
environment: test.pypi.org | |
environment_url: https://test.pypi.org/project/signalbot/${{ steps.create-custom-version.outputs.pr_version }}/ | |
log_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
state: success | |
env: | |
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | |
- name: Set deployment status to failure | |
id: failed_deployment | |
uses: octokit/[email protected] | |
if: failure() | |
with: | |
route: POST /repos/:repository/deployments/:deployment/statuses | |
repository: ${{ github.repository }} | |
deployment: ${{ fromJson(steps.create_deployment.outputs.data).id }} | |
environment: test.pypi.org | |
environment_url: https://test.pypi.org/project/signalbot/${{ steps.create-custom-version.outputs.pr_version }}/ | |
log_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
state: failure | |
env: | |
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" |