forked from LizardByte/Sunshine
-
Notifications
You must be signed in to change notification settings - Fork 0
107 lines (93 loc) · 3.74 KB
/
update-pacman-repo.yml
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
102
103
104
105
106
107
---
# This action is a candidate to centrally manage in https://github.com/<organization>/.github/
# If more pacman packages are developed, consider moving this action to the organization's .github repository,
# using the `pacman-pkg` repository label to identify repositories that should trigger have this workflow.
# Update pacman repo on release events.
name: Update pacman repo
on:
release:
types: [released]
concurrency:
group: "${{ github.workflow }}-${{ github.event.release.tag_name }}"
cancel-in-progress: true
jobs:
update-homebrew-release:
if: >-
github.repository_owner == 'LizardByte'
runs-on: ubuntu-latest
steps:
- name: Check if pacman repo
env:
TOPIC: pacman-pkg
id: check-label
uses: actions/github-script@v7
with:
script: |
const topic = process.env.TOPIC;
console.log(`Checking if repo has topic: ${topic}`);
const repoTopics = await github.rest.repos.getAllTopics({
owner: context.repo.owner,
repo: context.repo.repo
});
console.log(`Repo topics: ${repoTopics.data.names}`);
const hasTopic = repoTopics.data.names.includes(topic);
console.log(`Has topic: ${hasTopic}`);
core.setOutput('hasTopic', hasTopic);
- name: Check if latest GitHub release
id: check-release
if: >-
steps.check-label.outputs.hasTopic == 'true'
uses: actions/github-script@v7
with:
script: |
const latestRelease = await github.rest.repos.getLatestRelease({
owner: context.repo.owner,
repo: context.repo.repo
});
core.setOutput('isLatestRelease', latestRelease.data.tag_name === context.payload.release.tag_name);
- name: Checkout pacman-repo
if: >-
steps.check-label.outputs.hasTopic == 'true' &&
steps.check-release.outputs.isLatestRelease == 'true'
uses: actions/checkout@v4
with:
repository: ${{ github.repository_owner }}/pacman-repo
- name: Prep
id: prep
if: >-
steps.check-label.outputs.hasTopic == 'true' &&
steps.check-release.outputs.isLatestRelease == 'true'
run: |
echo "pkg_name=$(echo ${{ github.event.repository.name }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
- name: Download release asset
id: download
if: >-
steps.check-label.outputs.hasTopic == 'true' &&
steps.check-release.outputs.isLatestRelease == 'true'
uses: robinraju/[email protected]
with:
repository: "${{ github.repository }}"
tag: "${{ github.event.release.tag_name }}"
fileName: "*.pkg.tar.gz"
tarBall: false
zipBall: false
out-file-path: "pkgbuilds/${{ steps.prep.outputs.pkg_name }}"
extract: true
- name: Create/Update Pull Request
if: >-
steps.check-label.outputs.hasTopic == 'true' &&
steps.check-release.outputs.isLatestRelease == 'true' &&
fromJson(steps.download.outputs.downloaded_files)[0]
uses: peter-evans/create-pull-request@v7
with:
add-paths: |
pkgbuilds/*
token: ${{ secrets.GH_BOT_TOKEN }}
commit-message: "chore: Update ${{ github.repository }} to ${{ github.event.release.tag_name }}"
branch: bot/bump-${{ github.repository }}-${{ github.event.release.tag_name }}
delete-branch: true
title: "chore: Update ${{ github.repository }} to ${{ github.event.release.tag_name }}"
body: ${{ github.event.release.body }}
labels: |
auto-approve
auto-merge