Skip to content

Automate editorial style checking #313

Automate editorial style checking

Automate editorial style checking #313

Workflow file for this run

name: Review app on pull request
on:
pull_request_target:
types: [opened, closed, synchronize, reopened]
branches: [ main ]
jobs:
deploy:
if: github.event.action == 'opened' || github.event.action == 'reopened'
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
contents: read
environment:
name: PR review apps
steps:
- run: echo "πŸ”Ž The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
- name: Checkout code
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- run: echo "πŸ’‘ The ${{ github.repository }} repository has been cloned to the runner."
- run: echo "πŸ–₯️ The workflow is now ready to test your code on the runner."
- name: List files in the repository
run: |
ls ${{ github.workspace }}
- run: echo "🍏 This job's status is ${{ job.status }}."
- name: install clever-tools
run: npm install -g clever-tools
- name: Create app and configure app
env:
CLEVER_SECRET: ${{ secrets.CLEVER_SECRET }}
CLEVER_TOKEN: ${{ secrets.CLEVER_TOKEN }}
ORGA_ID: ${{ secrets.ORGA_ID }}
HUGO_VERSION: ${{ secrets.HUGO_VERSION }}
run: |
clever create --type static-apache doc-review-PR-${{ github.event.number }} --alias doc-review-PR-${{ github.event.number }} --region par --org "$ORGA_ID"
clever env set CC_PRE_BUILD_HOOK "./clevercloud-deploy-script.sh"
clever env set CC_WEBROOT "/public"
clever env set HUGO_ENV "production"
clever env set HUGO_VERSION "$HUGO_VERSION"
clever domain add doc-review-PR-${{ github.event.number }}.cleverapps.io
clever deploy
- name: Comment PR
uses: actions/github-script@v7
with:
script: |
const issue_number = context.payload.pull_request.number;
const message = `Deployment has finished πŸ‘οΈπŸ‘„πŸ‘οΈ Your app is available [here](https://doc-review-PR-${{ github.event.number }}.cleverapps.io)`;
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue_number,
body: message
});
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
update:
if: github.event.action == 'synchronize'
runs-on: ubuntu-latest
permissions:
issues: write
contents: read
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: install clever-tools
run: npm install -g clever-tools
- name: Link and update app
env:
CLEVER_SECRET: ${{ secrets.CLEVER_SECRET }}
CLEVER_TOKEN: ${{ secrets.CLEVER_TOKEN }}
ORGA_ID: ${{ secrets.ORGA_ID }}
run: |
clever link -o "$ORGA_ID" doc-review-PR-${{ github.event.number }}
clever deploy --force
- name: Comment PR
uses: actions/github-script@v7
with:
script: |
const issue_number = context.payload.pull_request.number;
const message = `πŸš€ Your app has been updated and is available [here](https://doc-review-PR-${{ github.event.number }}.cleverapps.io)`;
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue_number,
body: message
});
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
delete:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
if: always() && github.event_name == 'pull_request_target' && github.event.action == 'closed'
steps:
- name: install clever-tools
run: npm install -g clever-tools
- name: Delete app
env:
CLEVER_SECRET: ${{ secrets.CLEVER_SECRET }}
CLEVER_TOKEN: ${{ secrets.CLEVER_TOKEN }}
ORGA_ID: ${{ secrets.ORGA_ID }}
run: |
clever link -o "$ORGA_ID" doc-review-PR-${{ github.event.number }}
clever delete --alias doc-review-PR-${{ github.event.number }} --yes
- name: Comment PR
uses: actions/github-script@v7
with:
script: |
const issue_number = context.payload.pull_request.number;
const message = `Your review app has been deleted πŸ‘‹`;
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue_number,
body: message
});
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}