From 474fcd6af04f14855f64f13ccc66356c12b9a85f Mon Sep 17 00:00:00 2001 From: Bastian Eicher Date: Sat, 12 Dec 2020 20:05:32 +0100 Subject: [PATCH] Simplified GitHub workflows --- .github/workflows/publish.yml | 15 +++++++-------- .github/workflows/update.yml | 19 +++++-------------- .github/workflows/verify.yml | 11 +++++------ 0repo-config.py | 18 ++++++++---------- README.md | 4 ++-- watch.ps1 | 4 +--- watch.sh | 5 +---- 7 files changed, 29 insertions(+), 47 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 299623e9c..7fa03a8cb 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -17,15 +17,14 @@ jobs: with: path: public ref: gh-pages - - name: Set up repo + - name: Run 0repo run: | - cp feeds/0repo-config.py . - cp public/archives.db . mkdir incoming - git config --global user.name "apps.0install.net" - git config --global user.email "webmaster@0install.net" + ln -s feeds/0repo-config.py . + ln -s public/archives.db . echo "${{secrets.GPG_KEY}}" | gpg --import - - - name: Run 0repo - run: ./feeds/0install.sh run http://0install.net/tools/0repo.xml + ./feeds/0install.sh run http://0install.net/tools/0repo.xml - name: Push public - run: cd public && git push + run: | + cd public + git push diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml index 3a4c4e6ce..1f68e1ee6 100644 --- a/.github/workflows/update.yml +++ b/.github/workflows/update.yml @@ -13,11 +13,8 @@ jobs: uses: actions/checkout@v2 with: path: feeds - - name: Set up repo - run: mkdir incoming | Out-Null - name: Run 0watch env: - CI: '1' GITHUB_TOKEN: ${{github.token}} run: feeds\watch.ps1 - name: Upload generated feeds @@ -34,11 +31,8 @@ jobs: uses: actions/checkout@v2 with: path: feeds - - name: Set up repo - run: mkdir incoming - name: Run 0watch env: - CI: '1' GITHUB_TOKEN: ${{github.token}} run: feeds/watch.sh - name: Upload generated feeds @@ -61,14 +55,8 @@ jobs: with: path: public ref: gh-pages - - name: Set up repo - run: | - cp feeds/0repo-config.py . - cp public/archives.db . - mkdir incoming - name: Run 0watch env: - CI: '1' GITHUB_TOKEN: ${{github.token}} run: | sudo apt-get install -y python3-gnupg @@ -93,8 +81,11 @@ jobs: run: if ls incoming/*.xml; then echo "NEW_INCOMING=true" >> $GITHUB_ENV; fi - name: Run 0repo if: env.NEW_INCOMING - env: {'NO_SIGN': '1'} - run: ./feeds/0install.sh run http://0install.net/tools/0repo.xml + run: | + ln -s feeds/0repo-config.py . + ln -s public/archives.db . + export NO_SIGN=1 + ./feeds/0install.sh run http://0install.net/tools/0repo.xml - name: Create Pull Request if: env.NEW_INCOMING uses: peter-evans/create-pull-request@v3 diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index 5d4649575..1ba155241 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -15,11 +15,10 @@ jobs: with: path: public ref: gh-pages - - name: Set up repo + - name: Run 0repo run: | - cp feeds/0repo-config.py . - cp public/archives.db . mkdir incoming - - name: Run 0repo - env: {'NO_SIGN': '1'} - run: ./feeds/0install.sh run http://0install.net/tools/0repo.xml + ln -s feeds/0repo-config.py . + ln -s public/archives.db . + export NO_SIGN=1 + ./feeds/0install.sh run http://0install.net/tools/0repo.xml diff --git a/0repo-config.py b/0repo-config.py index 95df959d9..7d28b2d60 100644 --- a/0repo-config.py +++ b/0repo-config.py @@ -33,17 +33,15 @@ # also the current directory. # 'message' can be used if you want to log the reason for the update. def upload_public_dir(files, message): - if os.getenv('NO_SIGN'): - print("Feeds not signed; not committing public") + subprocess.check_call(['git', 'config', 'user.name', 'apps.0install.net']) + subprocess.check_call(['git', 'config', 'user.email', 'webmaster@0install.net']) + subprocess.check_call(['git', 'add', '--', 'archives.db'] + files) + changed = subprocess.call(['git', 'diff', '--exit-code', '--stat', 'HEAD', '--'] + files) + if changed: + subprocess.check_call(['git', 'commit', '-m', message]) + print("Changes to public committed. Remember to push!") else: - shutil.copyfile('../archives.db', 'archives.db') - subprocess.check_call(['git', 'add', '--', 'archives.db'] + files) - changed = subprocess.call(['git', 'diff', '--exit-code', '--stat', 'HEAD', '--'] + files) - if changed: - subprocess.check_call(['git', 'commit', '-m', message, '--', 'archives.db'] + files) - print("Changes to public committed. Remember to push!") - else: - print("No changes to public.") + print("No changes to public.") #### Archive hosting #### diff --git a/README.md b/README.md index cc16f51b7..027b1df7a 100644 --- a/README.md +++ b/README.md @@ -24,8 +24,8 @@ To work with this repository on your own machine run these commands inside an em git clone https://github.com/0install/apps.git feeds git clone https://github.com/0install/apps.git --single-branch --branch=gh-pages public - cp feeds/0repo-config.py . - cp public/archives.db . + ln -s feeds/0repo-config.py . + ln -s public/archives.db . mkdir incoming 0install add 0repo https://github.com/0install/0repo diff --git a/watch.ps1 b/watch.ps1 index 63e26e9e2..439644820 100644 --- a/watch.ps1 +++ b/watch.ps1 @@ -1,9 +1,7 @@ $ErrorActionPreference = "Stop" pushd $PSScriptRoot -if (-not (Test-Path "..\incoming" -PathType Container)) { - throw "Directory ..\incoming does not exist." -} +mkdir -Force ..\incoming | Out-Null cp *\*.zip ..\incoming\ foreach ($file in (ls -Recurse -Filter *.watch.py).FullName) { diff --git a/watch.sh b/watch.sh index 191cfca23..91fbf31b3 100755 --- a/watch.sh +++ b/watch.sh @@ -2,10 +2,7 @@ set -e cd `dirname $0` -if [ ! -d "../incoming" ]; then - echo "Directory ../incoming does not exist." - exit 1 -fi +mkdir -p ../incoming cp */*.zip ../incoming/ for FILE in $(ls */*.watch.py); do