-
Notifications
You must be signed in to change notification settings - Fork 4
96 lines (78 loc) · 3.25 KB
/
generate_index.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
name: Periodically generate the index file.
env:
# See: https://github.com/actions/setup-python/tree/main#available-versions-of-python
PYTHON_VERSION: "3.12"
INDEX_GENERATOR_LOC: "${{ github.workspace }}/olman-remote/index_generator.py"
ACCEPTED_REPOSITORIES_LOC: "${{ github.workspace }}/output_files/accepted_repositories.txt"
INDEX_FILE_LOC: "${{ github.workspace }}/output_files/remote_index.json"
INDEX_FILE_NAME: "remote_index.json"
on:
schedule:
- cron: "5 5 * * 5"
workflow_dispatch:
jobs:
generate:
runs-on: ubuntu-latest
outputs:
artifact: ${{ steps.configuration.outputs.artifact }}
path: ${{ steps.configuration.outputs.path }}
filename: ${{ steps.configuration.outputs.filename }}
steps:
- name: Set configuration outputs
id: configuration
run: |
echo "artifact=${{ env.INDEX_FILE_NAME }}" >> $GITHUB_OUTPUT
echo "path=${{ runner.temp }}" >> $GITHUB_OUTPUT
echo "filename=${{ env.INDEX_FILE_NAME }}" >> $GITHUB_OUTPUT
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: false
virtualenvs-in-project: false
- name: Install Libversion
run: |
. /etc/lsb-release
echo "deb [trusted=yes] https://download.opensuse.org/repositories/home:/t-paul:/libversion/xUbuntu_$DISTRIB_RELEASE/ ./" | sudo tee /etc/apt/sources.list.d/libversion.list
sudo apt update
sudo apt install libversion3-dev
- name: Install Dependencies
run: |
poetry install --directory="${{ github.workspace }}/olman-remote"
- name: Generate index
run: |
python${{ env.PYTHON_VERSION }} -u ${{ env.INDEX_GENERATOR_LOC }} \
--accepted-repositories ${{ env.ACCEPTED_REPOSITORIES_LOC }} \
--output ${{ steps.configuration.outputs.path }}/${{ steps.configuration.outputs.filename }} \
-v
cat ${{ steps.configuration.outputs.path }}/${{ steps.configuration.outputs.filename }}
- name: Upload index file to workflow artifact
uses: actions/upload-artifact@v4
with:
path: ${{ steps.configuration.outputs.path }}/${{ steps.configuration.outputs.filename }}
name: ${{ steps.configuration.outputs.artifact }}
update:
needs:
- generate
runs-on: ubuntu-latest
steps:
- name: Download index
uses: actions/[email protected]
with:
path: ${{ needs.generate.outputs.path }}
name: ${{ needs.generate.outputs.artifact }}
- name: Checkout repository
uses: actions/checkout@v4
- name: Add index file to repo
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHubBot OpenSCAD"
cat "${{ needs.generate.outputs.path }}/${{ needs.generate.outputs.filename }}" > "${{ env.INDEX_FILE_LOC }}"
git add --update "${{ env.INDEX_FILE_LOC }}"
git commit -m "Updated index ${{ github.run_id }}"
git push