Skip to content

Check Github Pages Gem Version and Open New Issue on Change #381

Check Github Pages Gem Version and Open New Issue on Change

Check Github Pages Gem Version and Open New Issue on Change #381

name: Check Github Pages Gem Version and Open New Issue on Change
on:
schedule:
- cron: "00 12 * * *"
workflow_dispatch:
jobs:
check-github-pages-gem-version:
runs-on: ubuntu-latest
steps:
- name: Check out Daniel Ridge repo
uses: actions/checkout@v4
- name: Set ENV variable for current ghpages-docker version number
run: echo "PAGES_CURRENT_VERSION=$(cat release-versions/github-pages-gem.txt)" >> $GITHUB_ENV
- name: Fetch GitHub Pages Gem release version and save in ENV variable
run: echo "PAGES_RELEASE_VERSION=$(curl -sL https://pages.github.com/versions.json | jq -r '."github-pages"')" >> $GITHUB_ENV
- name: Write release version to text file
run: |
echo ${{ env.PAGES_RELEASE_VERSION }} > release-versions/github-pages-gem.txt
- name: Check for modified files
id: git-check
run: |
if [ -z "$(git status --porcelain)" ]; then
echo "modified=false" >> $GITHUB_ENV
else
echo "modified=true" >> $GITHUB_ENV
fi
- name: Commit latest GH-Pages Gem release version
if: env.modified == 'true'
run: |
git config --global user.name 'Daniel Ridge'
git config --global user.email 'Daniel.Ridge@hackforla.org'
git commit -am "New release version"
git push
- name: Parse issue template
if: env.modified == 'true'
uses: actions/github-script@v8
id: parse-template
env:
PAGES_RELEASE_VERSION: ${{ env.PAGES_RELEASE_VERSION }}
PAGES_CURRENT_VERSION: ${{ env.PAGES_CURRENT_VERSION }}
with:
script: |
const PAGES_RELEASE_VERSION = process.env.PAGES_RELEASE_VERSION;
const PAGES_CURRENT_VERSION = process.env.PAGES_CURRENT_VERSION;
const script = require(
'./github-actions/utils/parse-issue-template.js'
);
const output = await script(
'./.github/ISSUE_TEMPLATE/update-gh-pages-version.md',
{ PAGES_RELEASE_VERSION, PAGES_CURRENT_VERSION }
);
core.setOutput('title', output.title);
core.setOutput('body', output.body);
core.setOutput('labels', output.labels);
core.setOutput('milestones', output.milestones);
core.setOutput('projects', output.projects);
- name: Create issue to update GH-Pages gem
if: env.modified == 'true'
env:
GH_TOKEN: ${{ secrets.DR_PAT }}
TITLE: ${{ steps.parse-template.outputs.title }}
BODY: ${{ steps.parse-template.outputs.body }}
LABELS: ${{ steps.parse-template.outputs.labels }}
MILESTONES: ${{ steps.parse-template.outputs.milestones }}
PROJECTS: ${{ steps.parse-template.outputs.projects }}
run: 'gh issue create
--repo "github.com/hackforla/ops"
--title "$TITLE"
--body "$BODY"
--label "$LABELS"
--milestone "$MILESTONES"
--project "$PROJECTS"'