Skip to content

missing checkout step #2

missing checkout step

missing checkout step #2

name: Ollama template update
on:
push: # for debugging
workflow_dispatch:
#schedule:
# - cron: '0 7 * * 1' # every monday at 7am, so I'll review it after having a 🥐
permissions:
pull-requests: write # for creating PR
issues: write # for adding labels to the created PR
contents: write # for git push new branch
jobs:
create-pull-request:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Prepare
id: prepare
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
npm install -g pnpm
CURRENT_DATE=$(date -u +"%Y-%m-%d")
echo "CURRENT_DATE=$CURRENT_DATE" >> $GITHUB_ENV
- name: Run update script
run: |
cd packages/ollama-utils
pnpm install --frozen-lockfile
pnpm run build:automap
- name: Check for changed files
id: changes
env:
CURRENT_DATE: ${{ steps.prepare.outputs.CURRENT_DATE }}
run: |
set -x
git status
modified_files="$(git status -s)"
echo "Modified files: ${modified_files}"
if [ -n "${modified_files}" ]; then
echo "Changes detected, will create a new branch:"
echo "${modified_files}"
git add -A
git commit -m "ollama update ${CURRENT_DATE}"
git checkout -b "ollama/${CURRENT_DATE}"
git push origin "ollama/${CURRENT_DATE}"
echo "HAS_CHANGES=true" >> $GITHUB_OUTPUT
else
echo "No files changed, skipping..."
echo "HAS_CHANGES=false" >> $GITHUB_OUTPUT
fi
- name: Create PR
if: steps.changes.outputs.HAS_CHANGES == 'true'
uses: actions/github-script@v6
env:
CURRENT_DATE: ${{ steps.prepare.outputs.CURRENT_DATE }}
with:
script: |
const { repo, owner } = context.repo;
const currDate = process.env.CURRENT_DATE;
const result = await github.rest.pulls.create({
title: '[ollama-utils] 🤖 Auto-update chat templates (' + currDate + ')',
owner,
repo,
head: '${{ github.ref_name }}',
base: 'main',
body: [
'This PR is auto-generated by',
'[generate-automap.ts](https://github.com/huggingface/huggingface.js/blob/main/packages/ollama-utils/scripts/generate-automap.ts).'
].join('\n')
});
console.log({ result });
// github.rest.issues.addLabels({
// owner,
// repo,
// issue_number: result.data.number,
// labels: ['feature', 'automated pr']
// });