Bump Cache Version #5
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: Bump Cache Version | |
on: | |
workflow_dispatch: | |
inputs: | |
cache_version: | |
description: "New @useblacksmith/cache version" | |
required: true | |
type: string | |
jobs: | |
bump-cache-version: | |
runs-on: blacksmith | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Create new branch | |
id: create-branch | |
run: | | |
git config user.name github-actions[bot] | |
git config user.email github-actions[bot]@users.noreply.github.com | |
git fetch origin master | |
git checkout master | |
git pull origin master | |
timestamp=$(date +%Y%m%d%H%M%S) | |
branch_name="bump-cache-version-${{ github.event.inputs.cache_version }}-$timestamp" | |
git checkout -b $branch_name | |
echo "branch_name=$branch_name" >> $GITHUB_OUTPUT | |
cd packages/setup-ocaml | |
- name: Update package.json | |
working-directory: packages/setup-ocaml | |
run: | | |
sed -i 's/"@actions\/cache": "npm:@useblacksmith\/cache@[^"]*"/"@actions\/cache": "npm:@useblacksmith\/cache@${{ github.event.inputs.cache_version }}"/' package.json | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18' | |
- name: Install Yarn | |
run: npm install -g [email protected] | |
- name: Install dependencies | |
working-directory: packages/setup-ocaml | |
run: yarn install | |
- name: Build | |
working-directory: packages/setup-ocaml | |
run: yarn build | |
- name: Check for changes | |
id: git-check | |
run: | | |
git diff --exit-code || echo "changes=true" >> $GITHUB_OUTPUT | |
- name: Create Pull Request | |
if: steps.git-check.outputs.changes == 'true' | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
git add . | |
git commit -m "Bump @actions/cache version to ${{ github.event.inputs.cache_version }}" | |
git push origin ${{ steps.create-branch.outputs.branch_name }} | |
gh pr create --title "Bump @actions/cache version to ${{ github.event.inputs.cache_version }}" --body "This PR updates the @actions/cache version to ${{ github.event.inputs.cache_version }}" |