Skip to content

Commit

Permalink
Simplified GitHub workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
bastianeicher committed Dec 12, 2020
1 parent ba50177 commit 474fcd6
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 47 deletions.
15 changes: 7 additions & 8 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 "[email protected]"
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
19 changes: 5 additions & 14 deletions .github/workflows/update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
11 changes: 5 additions & 6 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
18 changes: 8 additions & 10 deletions 0repo-config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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', '[email protected]'])
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 ####

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 1 addition & 3 deletions watch.ps1
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
5 changes: 1 addition & 4 deletions watch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 474fcd6

Please sign in to comment.