gpt4 book ai didi

github-actions - 有没有办法设置 Github 工作流/操作来更新草稿版本的标签、名称和目标?

转载 作者:行者123 更新时间:2023-12-04 07:58:18 25 4
gpt4 key购买 nike

我目前正在使用 Release Drafter每当 PR 合并到 develop 时创建草稿版本的工作流程分支(分期)。这创建了一个很棒的草稿,但现在我希望在将 develop 合并到 master 时将其发布。发生这种情况时,我需要在发布之前更新发布名称和标签。然后在我们的 Slack 工程 channel 中发出通知。
我能做的:

  • 设置push into master的 Action 。
  • 获取 latest draft release然后使用该 ID 作为引用。
  • 使用 eregon/publish-release 发布行动。
  • 发送slack消息

  • 我错过了什么:
  • 我可以传递发布 ID 并更新标签和名称的操作。

  • 名称和标签将是当前日期 %Y.%m%.d-%H:%M这是我迄今为止创建的操作 YML
    name: On master merged publish release & notify
    on:
    push:
    branches:
    - "master"
    jobs:
    release:
    name: Publish GitHub Release
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - name: Create tag from date
    id: create_tag
    run: |
    tag=builds-$(date +%Y.%m%.d__%H:%M)
    echo "::set-output name=tag::$tag" # https://github.com/ruby/ruby-dev-builder/blob/master/.github/workflows/build.yml
    - name: Get last Draft
    id: last_release
    uses: InsonusK/get-latest-release@v1.0.1 # https://github.com/InsonusK/get-latest-release
    with:
    myToken: ${{ github.token }} # TODO check if set
    exclude_types: "release"
    view_top: 1
    - name: "Print result"
    run: |
    echo "id: ${{ steps.last_release.outputs.id }}"
    echo "name: ${{ steps.last_release.outputs.name }}"
    echo "tag_name: ${{ steps.last_release.outputs.tag_name }}"
    echo "created_at: ${{ steps.last_release.outputs.created_atd }}"
    echo "draft: ${{ steps.last_release.outputs.draft }}"
    echo "prerelease: ${{ steps.last_release.outputs.prerelease }}"

    # This is Pseudocode.
    - name: update release
    id: update_release
    uses: tubone24/update_release@v1.0
    env:
    GITHUB_TOKEN: ${{ github.token }}
    with:
    tag: ${{ steps.create_tag.outputs.tag }}

    - name: Publish Release
    - uses: eregon/publish-release@v1 #https://github.com/elgohr/Github-Release-Action
    env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    with:
    release_id: ${{ steps.last_release.outputs.release_id }}
    # Needs test
    - name: Slack Notification Success
    uses: rtCamp/action-slack-notify@v2
    env:
    SLACK_CHANNEL: automated-deploys
    SLACK_COLOR: green
    SLACK_MESSAGE: ${{ steps.last_release.outputs.body }} # TODO get info
    SLACK_TITLE: Deploying 🚀
    SLACK_USERNAME: GH Action Parrot
    SLACK_ICON: https://emoji.slack-edge.com/T3LPQHAMV/headbangingparrot/1898efdc354c8ff8.gif
    SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}

    最佳答案

    您可以使用 Github 的 REST API 添加更新发布草案的步骤:

    - name: Update draft to ${{ github.event.client_payload.release_tag }}
    run: |
    curl \
    -u user:${{ secrets.USER_TOKEN }} \
    -X PATCH \
    -H "Accept: application/vnd.github.v3+json" \
    https://api.github.com/repos/{owner}/{repository}/releases/${{ steps.last_release.outputs.release_id }} \
    -d '{"tag_name":"${{ steps.last_release.outputs.tag_name }}", "name": "${{ steps.last_release.outputs.tag_name }}", "draft": "false"}'

    关于github-actions - 有没有办法设置 Github 工作流/操作来更新草稿版本的标签、名称和目标?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66592258/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com