Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
archive

GitHub Action

Development Freezer

v1.0.7

Development Freezer

archive

Development Freezer

Notify contributors about ongoing development freeze

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Development Freezer

uses: redhat-plumbers-in-action/devel-freezer@v1.0.7

Learn more about this action in redhat-plumbers-in-action/devel-freezer

Choose a version

Devel Freezer

GitHub Marketplace Unit Tests Linter CodeQL Check dist/ codecov Mergify Status

Devel Freezer is a GitHub Action that can automatically notify contributors of your open-source project about the state of development. When the project is in development freeze or when the development freeze has ended.

How does it work

TBA ...

Features

  • Ability to comment on Pull Requests predefined messages based on the latest tags
  • Ability to find and update comments from Devel Freezer GitHub Action
  • Policy based configuration using YAML syntax
  • Support for regular expressions for freezing tags definitions
  • And more ...

Usage

To setup Development freeze, we need three files:

  • Workflow that captures Pull Request metadata (number) and uploads this data as artifact
  • Workflow that runs on workflow-run trigger, downloads artifact and runs devel_freezer GitHub Action
  • development-freeze configuration

Note: Setup is complicated due to GitHub permissions on GITHUB_TOKEN. When used in workflow executed from fork it has read-only permissions. By using workflow-run trigger we are able to safely overcome this limitation and it allow us to comment on Pull Requests.

name: Gather Pull Request Metadata

on:
  pull_request:
    branches: [ main ]

env:
  PULL_REQUEST_METADATA_DIR: pull_request
  PULL_REQUEST_METADATA_FILE: metadata

permissions:
  contents: read

jobs:
  gather-metadata:
    runs-on: ubuntu-latest

    steps:
      - name: Repository checkout
        uses: actions/checkout@v3
        with:
          fetch-depth: 0

      - name: Store PR number in file
        run: |
          mkdir -p ./${{ env.PULL_REQUEST_METADATA_DIR }}
          echo ${{ github.event.number }} > ./${{ env.PULL_REQUEST_METADATA_DIR }}/${{ env.PULL_REQUEST_METADATA_FILE }}

      - name: Upload Pull Request Metadata artifact
        uses: actions/upload-artifact@v3
        with:
          name: ${{ env.PULL_REQUEST_METADATA_FILE }}
          path: ${{ env.PULL_REQUEST_METADATA_DIR }}
          retention-days: 1
name: Development Freeze

on:
  workflow_run:
    workflows: [ Gather Pull Request Metadata ]
    types:
      - completed

env:
  PULL_REQUEST_METADATA_DIR: pull_request
  PULL_REQUEST_METADATA_FILE: metadata

permissions:
  contents: read

jobs:
  freezer:
    if: >
      github.event.workflow_run.event == 'pull_request' &&
      github.event.workflow_run.conclusion == 'success'
    runs-on: ubuntu-latest
    
    permissions:
      issues: write
      pull-requests: write

    steps:
      - name: Download Pull Request Metadata artifact
        uses: actions/github-script@v6
        with:
          script: |
            var artifacts = await github.rest.actions.listWorkflowRunArtifacts({
               owner: context.repo.owner,
               repo: context.repo.repo,
               run_id: ${{ github.event.workflow_run.id }},
            });
            var matchArtifact = artifacts.data.artifacts.filter((artifact) => {
              return artifact.name == "${{ env.PULL_REQUEST_METADATA_FILE }}"
            })[0];
            var download = await github.rest.actions.downloadArtifact({
               owner: context.repo.owner,
               repo: context.repo.repo,
               artifact_id: matchArtifact.id,
               archive_format: 'zip',
            });
            const fs = require('fs');
            fs.writeFileSync('${{ github.workspace }}/${{ env.PULL_REQUEST_METADATA_FILE }}.zip', Buffer.from(download.data));
      - run: unzip ${{ env.PULL_REQUEST_METADATA_FILE }}.zip

      - name: 'Get Pull Request number'
        uses: actions/github-script@v6
        with:
          script: |
            const fs = require('fs');
            const pr_number = Number(fs.readFileSync('./${{ env.PULL_REQUEST_METADATA_FILE }}'));
            core.exportVariable('pr_number', pr_number);
          github-token: ${{ secrets.GITHUB_TOKEN }}

      - name: Repository checkout
        uses: actions/checkout@v3
        with:
          fetch-depth: 0

      - name: Development Freezer
        uses: redhat-plumbers-in-action/devel-freezer@v1
        with:
          pr-number: ${{ env.pr_number }}
          token: ${{ secrets.GITHUB_TOKEN }}

Note: fetch-depth: 0 is required in order to have access to full history including tags.

policy:
  - tags: ['alpha', 'beta']
    feedback:
      frozen-state: |
        ๐Ÿฅถ We are currently in ...
        ๐Ÿ™ Please ...
      unfreeze-state: |
        ๐Ÿ˜Ž We are no longer in ...

  # Suport for regular expressions
  - tags: ['^\S*-rc\d$']
    feedback:
      frozen-state: |
        We are currently in a development freeze phase.
        Please ...
      unfreeze-state: |
        We had successfully released a new major release.
        We are no longer in a development freeze phase.

Real-life examples

Feel free to try devel-freezer using template repository - @redhat-plumbers-in-action/development-freeze-automation

Configuration options

Action currently accepts the following options:

# ...

- uses: redhat-plumbers-in-action/devel-freezer@v1
  with:
    pr-number: <number>
    token: <GitHub token>

# ...

pr-number

Pull Request number.

  • default value: ${{ github.event.number }}
  • requirements: required

token

Token used to create comments. Minimal required permissions are contents: read and pull-requests: write

  • default value: undefined
  • requirements: required
  • recomended value: secrets.GITHUB_TOKEN

Policy

It's required to define a freezing policy for Action to behave correctly. The policy can be defined using .github/development-freeze.yml configuration file. The structure needs to be as follows:

policy:
  - tags: ['alpha', 'beta']
    feedback:
      frozen-state: |
        ๐Ÿฅถ We are currently in ...
        ๐Ÿ™ Please ...
      unfreeze-state: |
        ๐Ÿ˜Ž We are no longer in ...

  # Suport for regular expressions
  - tags: ['^\S*-rc\d$']
    feedback:
      frozen-state: |
        We are currently in a development freeze phase.
        Please ...
      unfreeze-state: |
        We had successfully released a new major release.
        We are no longer in a development freeze phase.
  # tags: ...

tags keyword

Array of tag names and/or regular expressions describing freezing tag scheme (e.g. ^\S*-rc\d$ for tags like v251-rc1, v252-rc2, etc.). Multiple freezing schemes are supported.

  • requirements: required

feedback.frozen-state keyword

The message that is going to be displayed in form of a comment when development freeze conditions are met. Support for a multi-line string using | YAML syntax.

  • requirements: required

feedback.unfreeze-state keyword

The message that is going to replace the development freeze message when development freeze conditions are no longer met. Support for a multi-line string using | YAML syntax.

  • requirements: required