Skip to content

Commit 1506e5a

Browse files
committed
Add upload-database.yml GitHub Actions workflow
1 parent 136ec6e commit 1506e5a

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed

.github/workflows/upload-database.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: Upload database
2+
3+
# This GitHub Actions workflow checkouts the PostGIS database dump
4+
# which was generated on @whkchow's computer. The 7-Zip archive
5+
# in 2000 MiB volumes, which were split into 100 MiB chunks for
6+
# storage in Git repo, are joined and uploaded as release assets
7+
# (for a tagged release) on GitHub.
8+
9+
on:
10+
push:
11+
# branches:
12+
# - '**'
13+
tags:
14+
- 'v*'
15+
workflow_dispatch:
16+
inputs:
17+
release_tag:
18+
description: "Release tag"
19+
required: true
20+
21+
concurrency: prevent-race-condition
22+
23+
jobs:
24+
upload-opendrr-database:
25+
runs-on: ubuntu-22.04
26+
env:
27+
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
28+
29+
steps:
30+
- name: Make more room by deleting unused software
31+
if: ${{ github.event_name != 'schedule' }}
32+
run: |
33+
set -x
34+
df -h
35+
du -csh /usr/share/dotnet
36+
du -csh /usr/local/lib/android
37+
sudo eatmydata rm -f -r /usr/share/dotnet
38+
sudo eatmydata rm -f -r /usr/local/lib/android
39+
df -h
40+
41+
- name: Checkout repository
42+
uses: actions/checkout@v3
43+
44+
- name: Install 7-Zip
45+
run: |
46+
sudo eatmydata apt update
47+
sudo eatmydata apt install -y 7zip
48+
sudo eatmydata apt clean
49+
50+
- name: Join 100 MiB chunks into 2000 MiB 7-Zip volumes
51+
run: |
52+
for i in *.7z.[0-9][0-9][0-9].aa; do
53+
j=$(basename $i .aa)
54+
cat $j.?? > $j
55+
rm $j.[a-z][a-z]
56+
done
57+
58+
- name: Extract opendrr-boundaries-db.dump for checking
59+
run: 7zz x opendrr-boundaries-db.7z.001
60+
61+
- name: Verify SHA256 checksum of opendrr-boundaries-db.dump
62+
run: |
63+
sha256sum -c opendrr-boundaries-db.dump.sha256sum
64+
rm -f -v opendrr-boundaries-db.dump
65+
66+
- name: "Upload database dump as GitHub artifact"
67+
uses: actions/upload-artifact@v3
68+
if: "!contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]')"
69+
with:
70+
name: opendrr-boundaries-db
71+
path: |
72+
*.7z.[0-9][0-9][0-9]
73+
*.sha256sum
74+
if-no-files-found: error
75+
76+
- name: "Upload database dump as release assets using xresloader/upload-to-github-release@v1"
77+
uses: xresloader/upload-to-github-release@v1
78+
env:
79+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
80+
with:
81+
file: "*.7z.[0-9][0-9][0-9];*.sha256sum"
82+
tag_name: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.release_tag || '' }}
83+
tags: true
84+
draft: false

0 commit comments

Comments
 (0)