Get latest Material for MkDocs Insiders version #89
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: Get latest Material for MkDocs Insiders version | |
on: | |
schedule: | |
- cron: '0 0 * * *' | |
workflow_dispatch: | |
permissions: | |
contents: write | |
pull-requests: write | |
env: | |
VERSION_FILE: version/mkdocs-material-insiders.txt | |
# The version already includes the 'insiders' suffix | |
DOWNLOAD_PREFIX: download/mkdocs-material | |
jobs: | |
get-latest-version: | |
environment: production | |
runs-on: ubuntu-latest | |
if: github.event.repository.fork == false | |
steps: | |
- name: Check-out repository | |
uses: actions/checkout@v4 | |
- name: Fetch latest release version | |
env: | |
GH_TOKEN: ${{ secrets.MKDOCS_TOKEN }} | |
id: fetch-latest | |
shell: bash | |
run: | | |
gh release view --repo "squidfunk/mkdocs-material-insiders" \ | |
--json "tagName" --jq ".tagName" | | |
tr -d '"' | sed 's/-insiders/+insiders/' > ${{ env.VERSION_FILE }} | |
echo "version=$(cat ${{ env.VERSION_FILE }})" >> $GITHUB_OUTPUT | |
- name: Check for modified files | |
id: check | |
shell: bash | |
run: | | |
echo "modified=$(if [ -n "$(git status --porcelain)" ]; then echo "true"; else echo "false"; fi)" >> $GITHUB_OUTPUT | |
- name: Create pull request | |
if: steps.check.outputs.modified == 'true' | |
id: create-pull-request | |
uses: peter-evans/create-pull-request@v6 | |
with: | |
commit-message: "⬆️ Update Material for MkDocs Insiders to ${{ steps.fetch-latest.outputs.version }}" | |
signoff: true | |
branch: "update/mkdocs-material/${{ steps.fetch-latest.outputs.version }}" | |
base: "main" | |
title: "⬆️ Update Material for MkDocs Insiders to ${{ steps.fetch-latest.outputs.version }}" | |
- name: Enable pull request auto-merge | |
if: steps.create-pull-request.outputs.pull-request-operation == 'created' | |
uses: peter-evans/enable-pull-request-automerge@v3 | |
with: | |
pull-request-number: ${{ steps.create-pull-request.outputs.pull-request-number }} | |
merge-method: squash | |
outputs: | |
version: ${{ steps.fetch-latest.outputs.version }} | |
is_new: ${{ steps.check.outputs.modified }} | |
upload-latest-version: | |
environment: production | |
runs-on: ubuntu-latest | |
needs: get-latest-version | |
if: needs.get-latest-version.outputs.is_new == 'true' | |
steps: | |
- name: Install dependencies | |
run: | | |
sudo apt install -y sshpass | |
- name: Download latest version | |
id: download | |
env: | |
GH_TOKEN: ${{ secrets.MKDOCS_TOKEN }} | |
OUTPUT_FILE: ${{ env.DOWNLOAD_PREFIX }}-${{ needs.get-latest-version.outputs.version }}.tar.gz | |
shell: bash | |
run: | | |
gh release download --repo "squidfunk/mkdocs-material-insiders" --archive "tar.gz" --output "${{ env.OUTPUT_FILE }}" | |
echo "file=${{ env.OUTPUT_FILE }}" >> $GITHUB_OUTPUT | |
- name: Upload latest version using SCP | |
env: | |
SSHPASS: ${{ secrets.SCP_PASSWORD }} | |
run: >- | |
sshpass -e scp | |
-P ${{ vars.SCP_PORT }} | |
-o StrictHostKeyChecking=no | |
${{ steps.download.outputs.file }} | |
${{ vars.SCP_USER }}@${{ vars.SCP_HOST }}:${{ vars.SCP_TARGET }} |