fix trial #21
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: Update Dependency | |
on: | |
push: | |
branches: | |
- '**' # Trigger on commits to any branch | |
permissions: | |
contents: write | |
pull-requests: write | |
jobs: | |
update-dependency: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up jq | |
run: sudo apt-get install jq | |
- name: Fetch latest version of dependency | |
id: fetch_version | |
run: | | |
# Fetch the latest version from the FirelyTeam/firely-terminal-pipeline GitHub repository | |
LATEST_VERSION=$(curl -s https://api.github.com/repos/FirelyTeam/firely-terminal-pipeline/releases/latest | jq -r .tag_name) | |
echo "LATEST_VERSION=$LATEST_VERSION" >> $GITHUB_ENV | |
- name: Update main.yml | |
run: | | |
# Update the main.yml file with the new version | |
sed -i "s|uses: FirelyTeam/firely-terminal-pipeline@.*|uses: FirelyTeam/firely-terminal-pipeline@$LATEST_VERSION|" .github/workflows/main.yml | |
- name: Commit changes | |
env: | |
WORKFLOW_PERMISSION_GITHUB: ${{ secrets.WORKFLOW_PERMISSION_GITHUB }} | |
run: | | |
# Commit the changes | |
git config --global user.name 'github-actions[bot]' | |
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
git checkout -b update-dependency-$LATEST_VERSION || git checkout update-dependency-$LATEST_VERSION | |
git add .github/workflows/main.yml | |
git commit -m "Update dependency to version $LATEST_VERSION" | |
git push https://x-access-token:${{ secrets.WORKFLOW_PERMISSION_GITHUB }}@github.com/${{ github.repository }}.git update-dependency-$LATEST_VERSION | |
- name: Create Pull Request | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const latestVersion = process.env.LATEST_VERSION; | |
const { data: pullRequest } = await github.rest.pulls.create({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
title: `Update dependency to version ${latestVersion}`, | |
head: `update-dependency-${latestVersion}`, | |
base: context.ref.replace('refs/heads/', ''), | |
body: `This PR updates the dependency to version ${latestVersion}.`, | |
maintainer_can_modify: true, | |
}); | |
console.log(`Created pull request: ${pullRequest.html_url}`); |