Skip to content

Update file "issue templates.yml" #9

Update file "issue templates.yml"

Update file "issue templates.yml" #9

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

View workflow run for this annotation

GitHub Actions / Get Last Two Branches

Invalid workflow file

The workflow is not valid. .github/workflows/issue templates.yml (Line: 10, Col: 3): The identifier 'update version-placeholder' is invalid. IDs may only contain alphanumeric characters, '_', and '-'. IDs must start with a letter or '_' and and must be less than 100 characters.
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