Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

question: how to use github context in config file? #1345

Open
h3n4l opened this issue Jun 7, 2023 · 1 comment
Open

question: how to use github context in config file? #1345

h3n4l opened this issue Jun 7, 2023 · 1 comment

Comments

@h3n4l
Copy link

h3n4l commented Jun 7, 2023

Hi, release-drafter team, I'm using release-drafter to create a release drafter when the tag push event fires.

But when I try to use the github context in the config file, it doesn't seem to work.

Here is the action file I use:

name: Build Release Artifacts and Draft Release

on:
  push:
    tags:
      - "*.*.*"

permissions:
  contents: read

draft-release:
    permissions:
      contents: write
      pull-requests: read
    runs-on: ubuntu-latest
    steps:
      - uses: release-drafter/release-drafter@v5
        name: Draft Release
        id: create-draft-release
        with:
          config-name: workflows-config/release-drafter.yml
          disable-autolabeler: true
          tag: ${{ github.ref_name }}
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Config file:

name-template: ${{ github.ref_name }} 🌈
template: |
  ## Changes
  $CHANGES

And IMO, the release name should be like 0.0.1 🌈, but I get the following:
CleanShot 2023-06-07 at 22 43 32@2x

Did I miss something?

@ahenriksen-esri
Copy link

ahenriksen-esri commented Jun 29, 2023

@h3n4l - One option you can try is to use environment variables to set the name config value in the .gitbub/workflow/release-drafter.yml file instead of in the template. We use date-based versioning for our project, so I did this:

# .github/workflows/release-drafter.yml

name: 'Release Drafter'
run-name: 'Release Drafter'

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]
    types: [ opened, reopened, synchronize ]

permissions:
  contents: read

jobs:
  update_release_draft:
    runs-on: [ ubuntu-latest ]
    name: Update Release Draft
    permissions:
      contents: write
      pull-requests: write
    steps:
      - name: Set Environment Variables
        run: |
          echo "RELEASE_NAME=[Draft] Next Release" >> $GITHUB_ENV
          echo "RELEASE_TAG=v$(date +'%Y.%m.%d')" >> $GITHUB_ENV
          echo "RELEASE_VERSION=v$(date +'%Y.%m.%d')" >> $GITHUB_ENV

      - name: Draft Release
        uses: release-drafter/release-drafter@v5.21.1
        with:
          commitish: main
          name: ${{ env.RELEASE_NAME }}
          tag: ${{ env.RELEASE_TAG }}
          version: ${{ env.RELEASE_VERSION }}
          publish: false
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants