Update file "issue templates.yml" #9
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: Get Last Two Branches | ||
on: | ||
push: | ||
branches: | ||
- '**' | ||
workflow_dispatch: | ||
jobs: | ||
update version-placeholder: | ||
Check failure on line 10 in .github/workflows/issue templates.yml
|
||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
- name: Get last two branches name | ||
id: get-branches | ||
run: | | ||
# List all branches sorted by commit date, then take the last two | ||
branches=$(git for-each-ref --sort=-committerdate refs/heads/ --format='%(refname:short)' | head -n 2) | ||
branch_array=($branches) | ||
echo "Branch 1: ${branch_array[0]}" | ||
echo "Branch 2: ${branch_array[1]}" | ||
# Set the outputs for use in other steps or jobs | ||
echo "::set-output name=branch1::${branch_array[0]}" | ||
echo "::set-output name=branch2::${branch_array[1]}" | ||
- name: Update placeholder in bug.yml | ||
run: | | ||
placeholder_to_replace="${{ steps.get-branches.outputs.branch1 }}" | ||
new_placeholder="${{ steps.get-branches.outputs.branch2 }}" | ||
# 檢查 .github/ISSUE_TEMPLATE/bug.yml 是否包含特定的 placeholder | ||
if grep -q "$placeholder_to_replace" .github/ISSUE_TEMPLATE/bug.yml; then | ||
# 使用 sed 命令替換 placeholder | ||
sed -i "s/$placeholder_to_replace/$new_placeholder/g" .github/ISSUE_TEMPLATE/bug.yml | ||
echo "Placeholder updated successfully." | ||
else | ||
echo "Placeholder not found." | ||
fi | ||
- name: Commit changes | ||
run: | | ||
git config --local user.email "[email protected]" | ||
git config --local user.name "GitHub Actions" | ||
git commit -am "Update file "bug.yml" placeholder" | ||
git push | ||