我正在try 更新一个go文件中的版本,但它失败了,出现了以下错误:

Run actions/github-script@v6
SyntaxError: Unexpected identifier
    at new AsyncFunction (<anonymous>)
    at callAsyncFunction (/home/runner/work/_actions/actions/github-script/v6/dist/index.js:15143:16)
    at main (/home/runner/work/_actions/actions/github-script/v6/dist/index.js:15236:26)
    at /home/runner/work/_actions/actions/github-script/v6/dist/index.js:15217:1
    at /home/runner/work/_actions/actions/github-script/v6/dist/index.js:15268:3
    at Object.<anonymous> (/home/runner/work/_actions/actions/github-script/v6/dist/index.js:15271:12)
    at Module._compile (node:internal/modules/cjs/loader:1198:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1252:10)
    at Module.load (node:internal/modules/cjs/loader:1076:32)
    at Function.Module._load (node:internal/modules/cjs/loader:911:12)
Error: Unhandled error: SyntaxError: Unexpected identifier
##[debug]Node Action run completed with exit code 1
##[debug]Finishing: Run actions/github-script@v6

你能解释一下工作流程出了什么问题吗?我们如何才能做到这一点?

以下是我的工作流程:

name: Update Values on Tag
        
on:
  push:
    tags:
      - 'v*' # Trigger only in case of new tag

jobs:
  update_values:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/github-script@v6
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          script: |
            git config --global user.email "jdbdsj@gmail.com"
            git config --global user.name "Github actions"
            echo "Release Tag: ${{ github.ref_name }}"
            release_tag="${{ github.ref_name }}"
            # Update the value in the specified file (replace with your details)
            sed -i "s/const version = .*/const version = \"$release_tag\"/" ./hackkerRankSolutions/version.go
            git add version.go
            git commit -m "Update version to $release_tag in actions.yaml"
            git push origin main

推荐答案

您使用actions/github-script@v6运行shell命令.不是为了那个.

试试这个方法:

name: Update version
on:
  push:
    tags:
      - 'v*' # Trigger only in case of new tag
        
jobs:
  update_version:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - name: Update version
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      run: |
        git config --global user.email "jdbdsj@gmail.com"
        git config --global user.name "Github actions"
        echo "Release Tag: ${{ github.ref_name }}"
        release_tag="${{ github.ref_name }}"
        # Update the value in the specified file (replace with your details)
        sed -i "s/const version = .*/const version = \"$release_tag\"/" ./hackkerRankSolutions/version.go
        git add version.go
        git commit -m "Update version to $release_tag in actions.yaml"
        git push origin main
            
        

Go相关问答推荐

如何使用我的 struct 化日志(log)记录格式使人panic ?

如何使用工作区方法扩展克隆的Golang库

Golang中的泛型 struct /接口列表

使用Go使用Gorm使用外键对数据进行排序

我可以在Golang中的另一个类型参数的基础上约束一个类型的参数吗?

日志(log)文件不在 golang 的日志(log)目录中

我怎样才能改进这个嵌套逻辑以使其正常工作并提高性能

如何解决构建Docker Compose时的权限被拒绝问题

golang gin 获取 cookie json

为什么docall在singleflight中使用go panic?

如何使用 Docker 引擎 SDK 和 Golang 运行 docker 挂载卷

如果 transaction.Commit 对带有 postgres 连接的 SQL 失败,您是否需要调用 transaction.RollBack

在 Golang 中,如何将接口作为泛型类型与 nil 进行比较?

如何在 golang 中同时加载 .env 文件和 os 环境变量

Golang 工作池实现意外工作

使用 `didip/tollbooth` 限制每小时最大请求数

Golang SSH客户端错误无法验证,try 的方法[无公钥],没有支持的方法

当 git clone 工作时,Go mod tidy 在私有存储库上失败

如何使用golang操作很长的字符串以避免内存不足

Scanner.Buffer - 最大值对自定义拆分没有影响?