Skip to content

Commit

Permalink
doc: update docs/github-actions.md
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Jul 28, 2024
1 parent eea1a03 commit 58991c4
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions docs/github-actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -958,6 +958,47 @@ steps:
version: 1.22.21
```

### 传递环境变量
<!--rehype:wrap-class=col-span-2-->

在 `ci.yml` 上保存环境变量

```yml
- name: Save commit message to environment variable
run: echo "COMMIT_MESSAGE=${{ github.event.head_commit.message }}" >> $GITHUB_ENV
```

在 `tag.yml` 上获取环境变量

```yml
- name: Read commit message
run: |
echo "Commit: ${{ github.event.workflow_run.head_commit.message }}"
```

### 触发下一个工作流

在 `tag.yml` 上添加判断 `tag` 创建成功触发 `tag-creation-success` 的工作流

```yml
- name: Trigger next workflow if successful
if: steps.check_success.outputs.success == 'true'
run: |
curl -X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-d '{"event_type": "tag-creation-success"}' \
https://api.github.com/repos/${{ github.repository }}/dispatches
```

在 `success.yml` 上监听

```yml
on:
repository_dispatch:
types: [tag-creation-success]
```

GitLab CI/CD 迁移到 GitHub Actions
---

Expand Down

0 comments on commit 58991c4

Please sign in to comment.