Skip to content

Intake

Intake #10

Workflow file for this run

name: Intake
on:
issues:
types: [opened, reopened]
issue_comment:
types: [created]
jobs:
capture-json:
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ github.token }}
steps:
- name: Check conditions and exit
if: (github.event_name == 'issue_comment') && (github.event.comment.body != '.create-pr')
run: exit 1
- uses: actions/checkout@v3
- name: Pre Issue Comment
if: github.event_name == 'issue_comment' || github.event_name == 'issues'
run: |
echo "🫡 initating intake.yml workflow" >> comment.txt
echo "Running workflow ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" >> comment.txt
gh issue comment ${{ github.event.issue.number }} -F comment.txt
rm comment.txt
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '20' # Set this to the node version you are using
- name: Get npm cache directory
id: npm-cache-dir
shell: bash
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
- uses: actions/cache@v3
id: npm-cache # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true'
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- run: npm i
- name: Run script and capture output
if: github.event_name == 'issue_comment' || github.event_name == 'issues'
id: issueForm
run: ./script/commentbody ${{ github.event.issue.number }}
- name: Initial Issue Comment
env:
JSON: ${{ toJSON(steps.issueForm.outputs) }}
if: github.event_name == 'issue_comment' || github.event_name == 'issues'
run: |
echo "Running workflow ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" >> comment.txt
echo "Here are the changes, they will be merged:" >> comment.txt
echo '```json' >> comment.txt
echo "${JSON}" >> comment.txt # Ensure proper quoting of JSON
echo '```' >> comment.txt
echo "Keep in mind ☝️ this hasn't yet been validated / sanitized." >> comment.txt
gh issue comment ${{ github.event.issue.number }} -F comment.txt
rm comment.txt
- env:
JSON: ${{ toJSON(steps.issueForm.outputs) }}
run: echo ${JSON}
- run: npm i
- name: Operation
id: op
run: |
./script/mkall \
--updateAll \
--date "${{ steps.issueForm.outputs.date }}" \
--githubUsername "${{ steps.issueForm.outputs.githubUsername }}" \
--googleCal "${{ steps.issueForm.outputs.googleCal }}" \
--ical "${{ steps.issueForm.outputs.ical }}" \
--linkedin "${{ steps.issueForm.outputs.linkedin }}" \
--meetup "${{ steps.issueForm.outputs.meetup }}" \
--name "${{ steps.issueForm.outputs.name }}" \
--presentations "${{ steps.issueForm.outputs.presentations }}" \
--profileImage "${{ steps.issueForm.outputs.profileImage }}" \
--slides "${{ steps.issueForm.outputs.slides }}" \
--slidesSource "${{ steps.issueForm.outputs.slidesSource }}" \
--presentationTitle "${{ steps.issueForm.outputs.presentationTitle }}" \
--eventTitle "${{ steps.issueForm.outputs.eventTitle }}" \
--website "${{ steps.issueForm.outputs.website }}"
git config user.name "github-actions"
git config user.email "github-actions@github.com"
git add .
- run: |
if [ -z $(git status --porcelain) ]; then
gh issue comment ${{ github.event.issue.number }} -b "No changes detected, exiting."
exit 1
fi
- run: |
git commit -m "Automated Content Changes"
git diff HEAD^ HEAD > changes.patch
echo "hash=$(sha256sum changes.patch | awk '{ print $1 }')" >> $GITHUB_OUTPUT
rm changes.patch
- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
id: cpr
with:
title: intake submission ${{ steps.issueForm.outputs.name }}
body: intake submission ${{ steps.issueForm.outputs.name }}
branch: auto-${{ steps.op.outputs.hash}}
- name: Follow Issue Comment
if: github.event_name == 'issue_comment' || github.event_name == 'issues'
run: |
echo "Automated pull request: ${{ steps.cpr.outputs.pull-request-url }}" >> comment.txt
gh issue comment ${{ github.event.issue.number }} -F comment.txt
rm comment.txt