[Talk Submission] Lisa #90
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: Intake | |
# responsible for watching issues come in from the | |
# intake form and creating a new pr based on the | |
# form field data | |
on: | |
issues: | |
types: [opened, reopened] | |
issue_comment: | |
types: [created] | |
jobs: | |
planner: | |
name: Determine which jobs to run | |
runs-on: ubuntu-latest | |
# To keep it simple name the step and output the same as job | |
outputs: | |
SHOULD_RUN: ${{ steps.detect.outputs.SHOULD_RUN }} | |
IS_EVENT: ${{ steps.detect.outputs.IS_EVENT }} | |
IS_TALK: ${{ steps.detect.outputs.IS_TALK }} | |
IS_COMMENT: ${{ steps.detect.outputs.IS_COMMENT }} | |
IS_ISSUE: ${{ steps.detect.outputs.IS_ISSUE }} | |
steps: | |
- id: detect | |
run: | | |
IS_TALK=$(echo "${{ contains(github.event.issue.labels.*.name, 'talk-submission') }}") | |
IS_EVENT=$(echo "${{ contains(github.event.issue.labels.*.name, 'event-submission') }}") | |
IS_COMMENT=$(echo "${{ github.event_name == 'issue_comment' && github.event.comment.body == '.create-pr' }}") | |
IS_ISSUE=$(echo "${{ github.event_name == 'issues' }}") | |
echo "IS_TALK=$IS_TALK" >> $GITHUB_OUTPUT | |
echo "IS_EVENT=$IS_EVENT" >> $GITHUB_OUTPUT | |
echo "IS_COMMENT=$IS_COMMENT" >> $GITHUB_OUTPUT | |
echo "IS_ISSUE=$IS_ISSUE" >> $GITHUB_OUTPUT | |
echo "SHOULD_RUN=false" >> $GITHUB_OUTPUT | |
if [ "$IS_TALK" = "true" ] || [ "$IS_EVENT" = "true" ]; then | |
if [ "$IS_COMMENT" = "true" ] || [ "$IS_ISSUE" = "true" ]; then | |
echo "SHOULD_RUN=true" >> $GITHUB_OUTPUT | |
fi | |
fi | |
process-issue: | |
runs-on: ubuntu-latest | |
needs: planner | |
if: needs.planner.outputs.SHOULD_RUN == 'true' | |
env: | |
GH_TOKEN: ${{ github.token }} | |
steps: | |
- run: | | |
echo ${{needs.planner.outputs.SHOULD_RUN}} | |
echo ${{needs.planner.outputs.IS_EVENT}} | |
echo ${{needs.planner.outputs.IS_TALK}} | |
- uses: actions/checkout@v3 | |
- name: Pre Issue Comment | |
if: github.event_name == 'issue_comment' || github.event_name == 'issues' | |
run: | | |
echo "🎉 Thank you for submitting a talk!" >> comment.txt | |
echo "The next few comments are going to be about autogenerating a pull request to get you added to the roster." >> comment.txt | |
echo "" >> comment.txt | |
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 | |
- if: needs.planner.outputs.IS_TALK == 'true' | |
run: | | |
gh issue edit ${{ github.event.issue.number }} --title "[Talk Submission] ${{ steps.issueForm.outputs.name }}" | |
- if: needs.planner.outputs.IS_EVENT == 'true' | |
run: | | |
gh issue edit ${{ github.event.issue.number }} --title "[Event Submission] ${{ steps.issueForm.outputs.date }}" | |
- name: Operation | |
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 "[email protected]" | |
git add . | |
- run: | | |
if [ -z $(git status --porcelain) ]; then | |
gh issue comment ${{ github.event.issue.number }} -b "No changes detected, exiting." | |
exit 1 | |
fi | |
- id: op | |
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: '[Talk PR] ${{ steps.issueForm.outputs.name }}' | |
body: '[Talk PR] ${{ 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 "[Talk PR] ${{ steps.issueForm.outputs.name }} ${{ steps.cpr.outputs.pull-request-url }}" >> comment.txt | |
gh issue comment ${{ github.event.issue.number }} -F comment.txt | |
rm comment.txt |