-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
75 lines (74 loc) · 2.62 KB
/
action.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
name: Update crate-dist mirror
author: Michał Górny
description: Fetch new upstream tags for a mirror and trigger crate dist builds for them
inputs:
ssh-private-key:
description: Private SSH key to use for pushing
required: true
directories:
description: Directories with Cargo.toml files to process
default: .
upstream-repo:
description: URL to fetch upstream repository from (the default is to query GitHub)
runs:
using: composite
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set SSH key up
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ inputs.ssh-private-key }}
- name: Add upstream remote (according to GitHub parent)
if: ${{ inputs.upstream-repo == '' }}
env:
GH_TOKEN: ${{ github.token }}
shell: bash
run: |
git remote add upstream $(gh repo view ${{ github.repository }} --json parent --template 'https://github.com/{{.parent.owner.login}}/{{.parent.name}}')
- name: Add upstream remote (explicitly specified)
if: ${{ inputs.upstream-repo != '' }}
shell: bash
run: |
git remote add upstream ${{ inputs.upstream-repo }}
- name: Fetch upstream tags
shell: bash
run: git ls-remote --sort=refname --refs --tags upstream | awk '{ print $2 }' > upstream-tags.txt
- name: Fetch our tags
shell: bash
run: git ls-remote --sort=refname --refs --tags | awk '{ print $2 }' > our-tags.txt
- name: Configure git for committing
shell: bash
run: |
git config --global user.email [email protected]
git config --global user.name gentoo-crate-dist
- name: Push new tags
shell: bash
run: |
WORKFLOW="
name: Create crate dist
on:
push:
tags:
- '*'
jobs:
crate-dist:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Create crate dist
uses: projg2/crate-dist-action@v1
with:
directories: ${{ inputs.directories }}
"
while read tag; do
git fetch upstream "${tag}" &&
git checkout FETCH_HEAD &&
git rm -rf --ignore-unmatch .github/workflows &&
mkdir -p .github/workflows &&
echo "${WORKFLOW}" > .github/workflows/crate-dist.yml &&
git add .github/workflows/crate-dist.yml &&
git commit -m "Replace workflows" &&
git push [email protected]:${{ github.repository }} HEAD:${tag} || exit 1
done < <(comm -13 our-tags.txt upstream-tags.txt)