build & deploy #86
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: '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 |