Skip to content

Merge pull request #300 from aminvakil/awx23.0.0 #1862

Merge pull request #300 from aminvakil/awx23.0.0

Merge pull request #300 from aminvakil/awx23.0.0 #1862

Workflow file for this run

---
name: CI
'on':
pull_request:
push:
jobs:
changed_pkgs:
runs-on: ubuntu-20.04
outputs:
matrix: ${{ steps.changed-pkgs.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: retrieve changed pkgs
id: changed-pkgs
run: |
CHANGED_DIRS=$(git diff --name-only ${{ github.event.before }}..${{ github.event.after }} | grep PKGBUILD | cut -d / -f 1)
if [ -z "$CHANGED_DIRS" ]; then CHANGED_DIRS=$(git diff --name-only origin/master..HEAD | grep PKGBUILD | cut -d / -f 1); fi
CHANGED_PKGS=$(for pkg in ${CHANGED_DIRS}; do echo -n '{"pkg":'; echo -n "\"$pkg"\"; echo -n "},"; done | sed 's/,\([^,]*\)$/\1/';)
echo "::set-output name=matrix::{\"include\":[${CHANGED_PKGS}]}"
makepkg:
needs: changed_pkgs
name: makepkg
runs-on: ubuntu-20.04
strategy:
matrix: ${{fromJson(needs.changed_pkgs.outputs.matrix)}}
steps:
- name: Check out the codebase.
uses: actions/checkout@v3
- name: Exit if pkg doesn't exist.
run: if [ ! -d "${{ matrix.pkg }}" ]; then exit 1; fi
- name: Pull devel image.
run: docker pull quay.io/aminvakil/archlinux:devel
- name: Run a container of devel image and mount package on it.
run: |
container_id=$(mktemp)
docker run --detach --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:ro -v "${PWD}/${{ matrix.pkg }}":/pkg quay.io/aminvakil/archlinux:devel > "${container_id}"
echo "container_id=$container_id" >> $GITHUB_ENV
- name: Execute stuff before makepkg if there is any.
run: |
if [ -f ci/"${{ matrix.pkg }}"/before_makepkg.sh ]; then
shellcheck ci/"${{ matrix.pkg }}"/before_makepkg.sh
docker exec -i "$(cat ${container_id})" sh < ci/"${{ matrix.pkg }}"/before_makepkg.sh
fi
- name: Upgrade all packages.
run: docker exec "$(cat ${container_id})" pacman -Syu --noconfirm
- name: Change ownership of package folder
run: "docker exec $(cat ${container_id}) chown -R devel: /pkg"
- name: Install namcap
run: docker exec "$(cat ${container_id})" pacman -Syu namcap --noconfirm
- name: Namcap!
run: if [ ! -f ci/"${{ matrix.pkg }}"/namcap_skip ]; then docker exec "$(cat ${container_id})" su devel sh -c "cd /pkg && namcap PKGBUILD"; fi
- name: Makepkg!
run: docker exec "$(cat ${container_id})" su devel sh -c "cd /pkg && makepkg -sri --check --noconfirm"
- name: Execute stuff after makepkg if there is any.
run: |
if [ -f ci/"${{ matrix.pkg }}"/after_makepkg.sh ]; then
shellcheck ci/"${{ matrix.pkg }}"/after_makepkg.sh
docker exec -i "$(cat ${container_id})" sh < ci/"${{ matrix.pkg }}"/after_makepkg.sh
fi
- name: Stop and remove container forcefully.
run: docker rm -f "$(cat ${container_id})"
aurpublish:
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
needs: [changed_pkgs,makepkg]
name: Push to AUR
runs-on: ubuntu-20.04
strategy:
matrix: ${{fromJson(needs.changed_pkgs.outputs.matrix)}}
steps:
- name: Check out the codebase.
uses: actions/checkout@v3
- name: Pull base image.
run: docker pull quay.io/aminvakil/archlinux:latest
- name: Run a container of base image and mount repository on it.
run: |
container_id=$(mktemp)
docker run --detach --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:ro quay.io/aminvakil/archlinux:latest > "${container_id}"
echo "container_id=$container_id" >> $GITHUB_ENV
- name: Install aurpublish
run: docker exec "$(cat ${container_id})" pacman -Syu aurpublish --noconfirm
- name: Configure ssh config
run: |
docker exec "$(cat ${container_id})" bash -c "mkdir -p /root/.ssh/keys"
docker exec "$(cat ${container_id})" bash -c "echo 'Host aur aur.archlinux.org' > /root/.ssh/config"
docker exec "$(cat ${container_id})" bash -c "echo ' User aur' >> /root/.ssh/config"
docker exec "$(cat ${container_id})" bash -c "echo ' Hostname aur.archlinux.org' >> /root/.ssh/config"
docker exec "$(cat ${container_id})" bash -c "echo ' IdentityFile ~/.ssh/keys/aur' >> /root/.ssh/config"
- name: Add aur.archlinux host key
run: docker exec "$(cat ${container_id})" bash -c "echo 'aur.archlinux.org,95.216.144.15 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBLMiLrP8pVi5BFX2i3vepSUnpedeiewE5XptnUnau+ZoeUOPkpoCgZZuYfpaIQfhhJJI5qgnjJmr4hyJbe/zxow=' > /root/.ssh/known_hosts"
- name: Configure git user.email and user.name
run: |
docker exec "$(cat ${container_id})" bash -c "git config --global user.email '[email protected]'"
docker exec "$(cat ${container_id})" bash -c "git config --global user.name 'Amin Vakil'"
- name: Configure ssh key
run: |
docker exec "$(cat ${container_id})" bash -c "echo '${{ secrets.AUR_KEY }}' > /root/.ssh/keys/aur"
docker exec "$(cat ${container_id})" bash -c "chmod 400 /root/.ssh/keys/aur"
- name: Aurpublish!
run: |
docker exec "$(cat ${container_id})" bash -c "mkdir /repo && cd /repo && git clone https://github.com/aminvakil/aur"
docker exec "$(cat ${container_id})" bash -c "cd /repo/aur && aurpublish ${{ matrix.pkg }}"
- name: Remove ssh key
run: docker exec "$(cat ${container_id})" bash -c "rm /root/.ssh/keys/aur"
- name: Stop and remove container forcefully.
run: docker rm -f "$(cat ${container_id})"