Skip to content

Check Ruby Version and Open New Issue on Change #348

Check Ruby Version and Open New Issue on Change

Check Ruby Version and Open New Issue on Change #348

name: Check Ruby Version and Open New Issue on Change
on:
workflow_run:
workflows: ["Check Github Pages Gem Version and Open New Issue on Change"]
types:
- completed
workflow_dispatch:
jobs:
check-ruby-version:
runs-on: ubuntu-latest
steps:
- name: Check out Daniel Ridge repo
uses: actions/checkout@v4
- name: Set ENV variable for current Ruby version number
run: echo "RUBY_CURRENT_VERSION=$(cat release-versions/ruby.txt)" >> $GITHUB_ENV
- name: Fetch Ruby release version and save in ENV variable
run: echo "RUBY_RELEASE_VERSION=$(curl -sL https://pages.github.com/versions.json | jq -r '."ruby"')" >> $GITHUB_ENV
- name: Write release version to text file
run: |
echo ${{ env.RUBY_RELEASE_VERSION }} > release-versions/ruby.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 Ruby 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:
RUBY_RELEASE_VERSION: ${{ env.RUBY_RELEASE_VERSION }}
RUBY_CURRENT_VERSION: ${{ env.RUBY_CURRENT_VERSION }}
with:
script: |
const RUBY_RELEASE_VERSION = process.env.RUBY_RELEASE_VERSION;
const RUBY_CURRENT_VERSION = process.env.RUBY_CURRENT_VERSION;
const script = require(
'./github-actions/utils/parse-issue-template.js'
);
const output = await script(
'./.github/ISSUE_TEMPLATE/update-ruby-version.md',
{ RUBY_RELEASE_VERSION, RUBY_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 Ruby
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"'