Skip to content

Always returns nil? #50

Always returns nil?

Always returns nil? #50

Workflow file for this run

name: Process Word Submission
on:
issues:
types: [opened, reopened, edited]
env:
SWIFT_IMAGE: swiftlang/swift@sha256:30154112a700a5a95fd1760716bd2040e8b735f54f081a4865823abdec67d17e
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BOT_ACCESS_TOKEN: ${{ secrets.BOT_ACCESS_TOKEN }}
permissions:
contents: write
pull-requests: write
issues: write
jobs:
add:
runs-on: ubuntu-22.04
if: contains(github.event.issue.labels.*.name, 'add-word')
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Update Issue Title
uses: actions/github-script@v4
with:
github-token: ${{ env.GITHUB_TOKEN }}
script: |
const issueBody = process.env.GITHUB_EVENT_PATH ? require(process.env.GITHUB_EVENT_PATH).issue.body : '';
const wordsSection = issueBody.split('### New Words')[1]?.split('### Parts of Speech (POS)')[0] || '';
const wordList = wordsSection.split('\n').filter(line => line.trim() !== '').map(line => line.trim());
const wordCount = wordList.length;
const newTitle = `Adding ${wordCount} new words`;
github.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
title: newTitle
});
- name: Cache Docker Image
id: cache-docker
uses: actions/cache@v4
with:
path: /tmp/.docker-cache
key: ${{ runner.os }}-swift-${{ env.SWIFT_IMAGE }}
- name: Load Docker Image from Cache
if: steps.cache-docker.outputs.cache-hit == 'true'
run: |
mkdir -p /tmp/.docker-cache
docker load -i /tmp/.docker-cache/swift_image.tar
- name: Pull Docker Image
if: steps.cache-docker.outputs.cache-hit != 'true'
run: |
docker pull ${{ env.SWIFT_IMAGE }}
mkdir -p /tmp/.docker-cache
docker save ${{ env.SWIFT_IMAGE }} -o /tmp/.docker-cache/swift_image.tar
- name: Export Issue Body to Text File
run: |
echo "${{ github.event.issue.body }}" > issue_body.txt
- name: Process Words and Update JSON
run: |
docker run --rm -e CI=true -v "$PWD:/host" -w /host $SWIFT_IMAGE swift .github/scripts/add-words.swift issue_body.txt
- name: Check for Changes
run: bash .github/scripts/check_for_changes.sh
id: check
- name: Create Pull Request
id: cpr
if: steps.check.outputs.changes == 'true'
uses: peter-evans/create-pull-request@v6
with:
token: ${{ env.BOT_ACCESS_TOKEN }}
add-paths: |
Sources/PhraseKit/Resources/_adjective.json
Sources/PhraseKit/Resources/_adverb.json
Sources/PhraseKit/Resources/_noun.json
Sources/PhraseKit/Resources/_verb.json
commit-message: ${{ github.event.issue.title }}
title: ${{ github.event.issue.title }}
branch: word-addition-${{ github.event.issue.number }}
delete-branch: true
labels: |
mb-cli
body: |
Closes #${{ github.event.issue.number }}
## Original Message
```markdown
${{ github.event.issue.body }}
```
committer: "mb-actions[bot] <markbattistella-bot@users.noreply.github.com>"
author: "mb-actions[bot] <markbattistella-bot@users.noreply.github.com>"
- name: Update Issue (Success)
if: steps.check.outputs.changes == 'true'
uses: actions/github-script@v4
with:
github-token: ${{ env.GITHUB_TOKEN }}
script: |
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'Thank you! Your word additions have been processed. They will be merged with PR #${{ steps.cpr.outputs.pull-request-number }}.'
})
- name: Update and Lock Issue (Failure)
if: steps.check.outputs.changes != 'true'
uses: actions/github-script@v4
with:
github-token: ${{ env.GITHUB_TOKEN }}
script: |
github.issues.lock({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
lock_reason: "resolved"
})
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'It looks like there is an issue with your submission. Please edit the original issue with your corrections, and it will be reprocessed.'
})