-
Notifications
You must be signed in to change notification settings - Fork 1
170 lines (170 loc) · 6.03 KB
/
build_and_deploy.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
name: 'build & deploy'
on:
pull_request:
push:
branches: [ stable, pdi-main ]
schedule:
- cron: '27 1 3 * *' # monthly build on 1st of each month, 1:27AM => stable
- cron: '27 2 * * *' # daily build at 2:27AM => pdi-main
jobs:
build:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
distrib: [ debian, fedora, ubuntu ]
steps:
- if: "github.event_name != 'schedule' || github.event.schedule != '27 2 * * *'"
name: Checkout packages
uses: actions/checkout@v4
- if: github.event.schedule == '27 2 * * *'
name: Checkout packages
uses: actions/checkout@v4
with: { ref: pdi-main }
- name: check version
id: version
run: |
set -x
echo "github.event.schedule == '27 2 * * *' ?"
echo "${{github.event.schedule}} == '27 2 * * *' ?"
echo "${{github.event.schedule == '27 2 * * *'}}"
if grep '^Version: *main' pdi/pdi.spec
then echo "pdi_prefix=pdi-main." >> $GITHUB_OUTPUT
else echo "pdi_prefix=" >> $GITHUB_OUTPUT
fi
- uses: docker/login-action@v3
with: { registry: "ghcr.io", username: "${{ github.actor }}", password: "${{ secrets.GITHUB_TOKEN }}" }
- name: Checkout builder script
uses: actions/checkout@v4
with:
repository: jbigot/pkg_builder
path: pkg_builder
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: '3.8'
- name: Install deps
run: |
set -x
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin
curl -o - https://www.aptly.info/pubkey.txt | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/aptly.gpg > /dev/null
echo "deb http://repo.aptly.info/ squeeze main" | sudo tee /etc/apt/sources.list.d/aptly.list
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install devscripts equivs aptly
pip3.8 install -r pkg_builder/requirements.txt
- name: Build packages
env:
KEY_PASSPHRASE: ${{ secrets.KEY_PASSPHRASE }}
DISTRIB: ${{ matrix.distrib }}
run: |
set -x
python3.8 pkg_builder/pkgbuild -D ${DISTRIB} -j 3 -p "${KEY_PASSPHRASE}"
- name: Upload artifact
uses: actions/upload-artifact@v4
id: artifact
with:
name: ${{steps.version.outputs.pdi_prefix}}${{ matrix.distrib }}
path: ./${{steps.version.outputs.pdi_prefix}}${{ matrix.distrib }}
- name: Make artifact descriptor container
run: |
set -x
echo "${{ github.run_id }}" > run_id
tar -c run_id | docker import - ghcr.io/pdidev/pkgs/lastbuild:${{steps.version.outputs.pdi_prefix}}${{ matrix.distrib }}
docker push ghcr.io/pdidev/pkgs/lastbuild:${{steps.version.outputs.pdi_prefix}}${{ matrix.distrib }}
aggregate:
if: ${{ always() && github.event_name != 'pull_request' }}
needs: build
runs-on: ubuntu-20.04
steps:
- if: "github.event_name != 'schedule' || github.event.schedule != '27 2 * * *'"
name: Checkout packages
uses: actions/checkout@v4
with: { path: data }
- if: github.event.schedule == '27 2 * * *'
name: Checkout packages
uses: actions/checkout@v4
with: { path: data, ref: pdi-main }
- name: Aggregate sources
id: ident
run: |
set -x
mkdir _site
cp data/README.tpl/index.html _site
rm -rf data
for DISTRIB in debian fedora ubuntu pdi-main.debian pdi-main.fedora pdi-main.ubuntu
do
docker pull ghcr.io/pdidev/pkgs/lastbuild:${DISTRIB} || continue
CID="$(docker create ghcr.io/pdidev/pkgs/lastbuild:${DISTRIB} /bin/bash)"
docker cp "${CID}:run_id" "${DISTRIB}.run_id"
RUN_ID="$(sed 's/\./_/g' <<< "${DISTRIB}_run_id")"
echo "${RUN_ID}=$(cat ${DISTRIB}.run_id)" >> $GITHUB_OUTPUT
done
- uses: actions/download-artifact@v4
continue-on-error: true
with:
name: debian
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{steps.ident.outputs.debian_run_id}}
path: _site/debian
- uses: actions/download-artifact@v4
continue-on-error: true
with:
name: fedora
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{steps.ident.outputs.fedora_run_id}}
path: _site/fedora
- uses: actions/download-artifact@v4
continue-on-error: true
with:
name: ubuntu
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{steps.ident.outputs.ubuntu_run_id}}
path: _site/ubuntu
- uses: actions/download-artifact@v4
continue-on-error: true
with:
name: pdi-main.debian
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{steps.ident.outputs.pdi-main_debian_run_id}}
path: _site/pdi-main.debian
- uses: actions/download-artifact@v4
continue-on-error: true
with:
name: pdi-main.fedora
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{steps.ident.outputs.pdi-main_fedora_run_id}}
path: _site/pdi-main.fedora
- uses: actions/download-artifact@v4
continue-on-error: true
with:
name: pdi-main.ubuntu
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{steps.ident.outputs.pdi-main_ubuntu_run_id}}
path: _site/pdi-main.ubuntu
- name: Link to pdi-master
run: |
set -x
cd _site
for DISTRIB in debian fedora ubuntu
do
if [ -d "pdi-main.${DISTRIB}" ]
then ln -s "pdi-main.${DISTRIB}" "pdi-master.${DISTRIB}"
fi
done
- name: Upload page artifact
uses: actions/upload-pages-artifact@v3
publish:
needs: aggregate
if: "${{ always() && needs.aggregate.result == 'success' }}"
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4