Github Action Workflow Warning: Context access might be invalid
Update
想了一下 虽然没有错误,但其实设置环境 变量不是很好的习惯, 这种可以分成两个job
第一个job 先判断是否有相应变化,之后用outputs 传送给下一个 job 修改了
这个报警 还是有道理的 如果系统环境发生什么故障,设置环境变量失败,后续可能会有bug。
------
name: Auto Branch Creation
on:
issues:
types:
- opened
- edited
permissions:
contents: write
jobs:
create-branch:
runs-on: ubuntu-latest
steps:
- name: Check if branch needs to be created and determine type
id: check-branch
run: |
ISSUE_TITLE="${{ github.event.issue.title }}"
echo "Issue Title: $ISSUE_TITLE"
# Check if the title contains FEATURE or BUG
if echo "$ISSUE_TITLE" | grep -iq "FEATURE"; then
echo "Branch type: feature"
echo "branch_type=feature" >> $GITHUB_ENV
echo "create_branch=true" >> $GITHUB_ENV
elif echo "$ISSUE_TITLE" | grep -iq "BUG"; then
echo "Branch type: bug"
echo "branch_type=bug" >> $GITHUB_ENV
echo "create_branch=true" >> $GITHUB_ENV
else
echo "Branch creation not required."
echo "create_branch=false" >> $GITHUB_ENV
fi
- name: Exit if branch creation is not required
if: env.create_branch == 'false'
run: echo "No branch will be created for this issue."
- name: Check out the repository
if: env.create_branch == 'true'
uses: actions/checkout@v2
- name: Set up Git
if: env.create_branch == 'true'
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
- name: Create branch based on type
if: env.create_branch == 'true'
env:
ISSUE_NUMBER: ${{ github.event.issue.number }}
BRANCH_TYPE: ${{ env.branch_type }}
run: |
# Generate the branch name
BRANCH_NAME="${BRANCH_TYPE}/issue-${ISSUE_NUMBER}"
echo "Creating branch: $BRANCH_NAME"
# Create and push the branch
git checkout -b "$BRANCH_NAME"
git push "https://${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git" "$BRANCH_NAME"
对于使用环境变量来 进行自定义的 情况下, 虽然这样并没有错误但是目前 extension 没有办法判断是否是有问题所以会报出warning。 目前官方已经认可是 extension的问题, 将来可能会屏蔽相关告警的办法, 目前的warning 无视即可。
https://github.com/github/vscode-github-actions/issues/47
原文地址:https://blog.csdn.net/weixin_38990443/article/details/143909277
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!