Skip to content

update

update #1578

Workflow file for this run

name: update
on:
workflow_dispatch:
schedule:
- cron: "15 22 * * *"
permissions:
contents: write
jobs:
update:
if: github.repository == 'slack-ruby/slack-api-ref'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
ruby-version: '3.4'
- name: Download
run: bundle exec rake api:ref:download
- name: Update
run: bundle exec rake api:update
- name: Validate
run: bundle exec rake api:validate
- name: Get current date
run: echo "CURRENT_DATE=$(date +%Y/%m/%d)" >> $GITHUB_ENV
- name: Check for changes
id: changes
run: |
if git diff --quiet; then
echo "changed=false" >> "$GITHUB_OUTPUT"
else
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
- name: Prepare diff for AI summary
if: steps.changes.outputs.changed == 'true'
run: |
git diff --stat | sed 's/^/ /' > /tmp/diff_stat.txt
git diff | head -c 20000 | sed 's/^/ /' > /tmp/diff.txt
- name: Set up Node
if: steps.changes.outputs.changed == 'true'
uses: actions/setup-node@v6
- name: Install Copilot CLI
if: steps.changes.outputs.changed == 'true'
run: npm install -g @github/copilot
- name: Generate commit message with AI
if: steps.changes.outputs.changed == 'true'
id: ai
uses: actions/ai-inference@v3
with:
prompt-file: ./.github/prompts/commit-message.prompt.yml
model: ''
file_input: |
diff_stat: /tmp/diff_stat.txt
diff: /tmp/diff.txt
env:
COPILOT_GITHUB_TOKEN: ${{ secrets.COPILOT_PAT }}
- name: Build commit message
id: message
run: |
title=""
summary=""
if [ "${{ steps.changes.outputs.changed }}" = "true" ]; then
response="$(grep -v '^```' "${{ steps.ai.outputs.response-file }}" 2>/dev/null)"
title="$(echo "$response" | jq -r '.title // empty' 2>/dev/null)"
summary="$(echo "$response" | jq -r '.summary // empty' 2>/dev/null)"
fi
if [ -z "$title" ]; then
title="Updated from Slack docs, ${CURRENT_DATE}"
summary=""
fi
{
echo 'message<<COMMIT_MESSAGE_EOF'
echo "$title"
echo ""
echo "$summary"
echo 'COMMIT_MESSAGE_EOF'
} >> "$GITHUB_OUTPUT"
- name: Commit changes
uses: EndBug/add-and-commit@v9
with:
author_name: Slack API Ref Buildbot
author_email: buildbot@slack-api-ref.com
message: ${{ steps.message.outputs.message }}