update-github-actions-version

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Update GitHub Actions Version

更新GitHub Actions版本

Update action versions in GitHub Actions workflow files, focusing on major version changes only.
更新GitHub Actions工作流文件中的Action版本,仅聚焦于主版本变更。

Important Principles: Explanation of GitHub Actions Version Tagging System

重要原则:GitHub Actions版本标记系统说明

  • Using a major version number (e.g.,
    v4
    ) automatically fetches the latest minor and patch versions.
  • For example,
    actions/checkout@v4
    will automatically get versions like
    v4.2.2
    ,
    v4.3.0
    .
  • Do not update from
    v4
    to a specific version like
    v4.2.2
    — this is unnecessary.
  • Only update when the major version changes (e.g., from
    v5
    to
    v6
    ).
Note: Skip
fatjyc/update-submodule-action@v6.0
updates as the new version is broken.
  • 使用主版本号(例如
    v4
    )会自动获取最新的次版本和补丁版本。
  • 例如,
    actions/checkout@v4
    会自动获取
    v4.2.2
    v4.3.0
    等版本。
  • 请勿
    v4
    更新到特定版本如
    v4.2.2
    ——这毫无必要。
  • 仅在主版本变更时进行更新(例如从
    v5
    升级到
    v6
    )。
注意: 跳过
fatjyc/update-submodule-action@v6.0
的更新,因为新版本存在问题。

Steps

步骤

0. Find Workflow Files

0. 查找工作流文件

Look for files in
.github/workflows/
recursively. Note that composite actions may be used — read both the composite action and the calling workflow simultaneously.
递归查找
.github/workflows/
目录下的文件。注意可能会使用复合Action——需同时查看复合Action和调用它的工作流。

1. Check Current Versions

1. 检查当前版本

Analyze the action versions used in the workflow files.
分析工作流文件中使用的Action版本。

2. Query Latest Versions

2. 查询最新版本

Query each action's latest version:
https://github.com/{owner}/{repo}/releases/latest
查询每个Action的最新版本:
https://github.com/{owner}/{repo}/releases/latest

3. Identify Actions Needing Updates

3. 识别需要更新的Action

Only update actions where the major version has changed:
  • ✅ Update:
    docker/build-push-action@v5
    @v6
  • ❌ Skip:
    actions/checkout@v4
    @v4.2.2
Note: Skip
fatjyc/update-submodule-action@v6.0
updates as the new version is broken and v6.0 is fine.
仅更新主版本发生变更的Action:
  • ✅ 可更新:
    docker/build-push-action@v5
    @v6
  • ❌ 需跳过:
    actions/checkout@v4
    @v4.2.2
注意: 跳过
fatjyc/update-submodule-action@v6.0
的更新,因为新版本存在问题,而v6.0运行正常。

4. Obtain Changelogs

4. 获取变更日志

For actions requiring updates, retrieve changelogs to understand breaking changes.
对于需要更新的Action,获取其变更日志以了解破坏性变更。

5. Update Files

5. 更新文件

Update version numbers and make adjustments for any breaking changes.
更新版本号,并针对破坏性变更进行相应调整。

6. Commit Changes

6. 提交变更

Git add and commit your changes with a clear message indicating the updates made.
使用Git添加并提交变更,提交信息需清晰说明所做的更新。

Example Illustration

示例说明

✅ Correct Update

✅ 正确的更新方式

yaml
undefined
yaml
undefined

From

原内容

uses: docker/build-push-action@v5
uses: docker/build-push-action@v5

Update to

更新后

uses: docker/build-push-action@v6
undefined
uses: docker/build-push-action@v6
undefined

❌ Incorrect Update (Unnecessary)

❌ 错误的更新方式(无必要)

yaml
undefined
yaml
undefined

From

原内容

uses: actions/checkout@v4
uses: actions/checkout@v4

Incorrectly updated to

错误更新为

uses: actions/checkout@v4 .2 .2
undefined
uses: actions/checkout@v4.2.2
undefined

✅ Correct Practice (Keep Unchanged)

✅ 正确的做法(保持不变)

yaml
undefined
yaml
undefined

Keep unchanged

保持不变

uses :actions / checkout @ v 4
GitHub will automatically use the latest v 4.x.x release
undefined
uses: actions/checkout@v4
GitHub会自动使用最新的v4.x.x版本
undefined