Skip to content

fix name

fix name #30

Workflow file for this run

name: Update Dependency
on: # Trigger on commits to any branch and manual trigger
workflow_dispatch: # Allows manual trigger
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
with:
token: ${{ secrets.WORKFLOW_PERMISSION_GITHUB }} # Personal access token with workflow permissions
- name: Set up jq
run: sudo apt-get install jq
- name: Fetch latest version of firely terminal 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
# TODO add an if statement to prevent the workflow from running if the version is the same as the one in the main.yml file
- 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:
GITHUB_TOKEN: ${{ github.token }}
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}`);