我创建了一个 .yml github 工作流程,当我创建拉取请求时必须执行该工作流程,但我不知道为什么它不执行。
我想做的是:
test
的 feature/hosting/test
将其分配给 firebase 中的部署通道jq
这是我的.yml
name: Firebase Test Deploy
on:
pull_request:
branches:
- bugfix/hosting/*
- feature/hosting/*
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '14'
- name: Install Firebase CLI
run: npm install -g firebase-tools
- name: Get branch name
id: get_branch_name
run: echo "::set-output name=branch::$(echo $GITHUB_REF | cut -d/ -f2-)"
- name: Deploy to Firebase
run: |
cd functions && firebase use --token $FIREBASE_TOKEN
firebase hosting:channel:deploy ${{ steps.get_branch_name.outputs.branch }} --only hosting
env:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
- name: Install jq
run: sudo apt-get update -y && sudo apt-get install -y jq
- name: Get Hosting URL
id: get_hosting_url
run: |
hosting_url=$(firebase hosting:channel:list --json | jq -r '.[0].url')
echo "::set-output name=hosting_url::$hosting_url"
shell: bash
- name: Comment on Pull Request
uses: actions/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { context, github } = require('@actions/github');
const comment = `
**Firebase Hosting URL:**
${steps.get_hosting_url.outputs.hosting_url}
`;
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment,
})
.yml 文件的路径是
.github/workflows
。
错误在哪里?
如果
.yml
工作流程文件是在您希望触发工作流程的同一分支 (feature/hosting/disable-credit-card
) 中创建的,并且该工作流程文件尚未合并到基础分支中,则不会为该工作流程触发工作流程。拉取请求。 GitHub Actions 将仅识别拉取请求的基本分支中的工作流程文件。这可能就是您面临的问题。
将工作流程文件直接添加到您要定位的基础分支(通常是
main
或 master
)。