Periodically generate the index file. #17
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: "30 * * * *" | |
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 |