-
Notifications
You must be signed in to change notification settings - Fork 1
101 lines (87 loc) · 3.59 KB
/
update.yaml
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# This workflow runs nightly and pulls in new version of packit and
# outpack_server into this repository, by running the `scripts/update.py`
# script.
#
# If any updates are found, a pull request is created with the changes. If an
# open pull request already exists, it is updated instead.
#
# In addition to running automatically, this workflow may be triggered
# manually. When doing so, one may specify a particular Git ref to update
# either package to.
#
# Using the `gh` command-line tool, assuming mrc-1234 is a valid branch on the
# mrc-ide/packit repository:
#
# ```
# gh workflow run -R reside-ic/packit-infra update.yaml -f packit=mrc-1234
# ```
name: Update packages
on:
schedule:
- cron: '0 0 * * *' # Daily at midnight UTC
workflow_dispatch:
inputs:
outpack_server:
description: 'Git ref from which to update outpack_server'
type: string
packit:
description: 'Git ref from which to update packit'
type: string
jobs:
update:
runs-on: ubuntu-22.04
permissions:
pull-requests: write
contents: write
steps:
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- name: Update outpack_server
run: nix run .#update outpack_server -- --ref ${{ inputs.outpack_server || 'HEAD' }} --write-commit-log ${{ runner.temp }}/outpack_server.md
- name: Update packit
run: nix run .#update packit -- --ref ${{ inputs.packit || 'HEAD' }} --write-commit-log ${{ runner.temp }}/packit.md
- name: Prepare PR message
uses: actions/github-script@v7
id: prepare-message
with:
script: |
const fs = require("fs");
const lf = new Intl.ListFormat('en');
var packages = [];
var message = "";
for (const p of ["outpack_server", "packit"]) {
if (fs.existsSync(`${process.env.RUNNER_TEMP}/${p}.md`)) {
var sources = JSON.parse(fs.readFileSync(`packages/${p}/sources.json`));
message += `# Updating ${p} to ${sources.src.rev}\n`;
message += fs.readFileSync(`${process.env.RUNNER_TEMP}/${p}.md`);
packages.push(p);
}
}
core.setOutput('title', "Update " + lf.format(packages));
core.setOutput('body', message);
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
id: create-pr
with:
branch: actions/update-packages
title: ${{ steps.prepare-message.outputs.title }}
body: ${{ steps.prepare-message.outputs.body }}
commit-message: |
${{ steps.prepare-message.outputs.title }}
${{ steps.prepare-message.outputs.body }}
reviewers: plietar
- name: Comment hint
uses: thollander/actions-comment-pull-request@v3
if: steps.create-pr.outputs.pull-request-operation == 'created'
with:
pr-number: ${{ steps.create-pr.outputs.pull-request-number }}
message: |
You can deploy this pull request by running the following command:
```sh
nix run "github:${{ github.repository }}?ref=refs/pull/${{ steps.create-pr.outputs.pull-request-number }}/merge#deploy" <hostname>
```
After merging this pull request, you must deploy the ${{ github.event.repository.default_branch }} branch to each host by running the following command:
```sh
nix run "github:${{ github.repository }}#deploy" <hostname>
```