summaryrefslogtreecommitdiffstats
path: root/.github/workflows/development_freeze.yml
blob: 17065b24d27534f48a86c2002f64d9559f834f4e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# doc: https://github.com/redhat-plumbers-in-action/devel-freezer#readme
---

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' &&
      github.repository == 'systemd/systemd'
    runs-on: ubuntu-22.04

    permissions:
      pull-requests: write

    steps:
      - name: Download Pull Request Metadata artifact
        uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410
        with:
          script: |
            const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
               owner: context.repo.owner,
               repo: context.repo.repo,
               run_id: ${{ github.event.workflow_run.id }},
            });

            const matchArtifact = artifacts.data.artifacts.filter((artifact) => {
              return artifact.name == "${{ env.PULL_REQUEST_METADATA_FILE }}"
            })[0];

            const 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@d7906e4ad0b1822421a7e6a35d5ca353c962f410
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          script: |
            const fs = require('fs');
            const pr_number = Number(fs.readFileSync('./${{ env.PULL_REQUEST_METADATA_FILE }}'));
            core.exportVariable('pr_number', pr_number);

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

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