Skip to content

Commit

Permalink
Push yq to image
Browse files Browse the repository at this point in the history
  • Loading branch information
yhaliaw committed Nov 16, 2023
1 parent 4476080 commit b13b401
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ jobs:
with:
channel: 5.19/stable
- uses: actions/checkout@v4
- name: Install wget
run: sudo apt update && sudo apt install -yq wget
- name: Run build script
run: bash scripts/build-image.sh
- uses: actions/upload-artifact@v3
Expand Down
23 changes: 11 additions & 12 deletions scripts/build-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ done
/snap/bin/lxc exec runner -- /usr/sbin/iptables -I DOCKER-USER -j ACCEPT

# Set up aproxy for downloading
/snap/bin/lxc exec runner -- /usr/bin/snap install aproxy --edge
/snap/bin/lxc exec runner -- /usr/bin/snap set aproxy proxy=squid.internal:3128
/snap/bin/lxc exec runner -- sh -c 'nft -f - << EOF
/usr/bin/snap install aproxy --edge
/usr/bin/snap set aproxy proxy=squid.internal:3128
nft -f - << EOF
define default-ip = $(ip route get $(ip route show 0.0.0.0/0 | grep -oP 'via \K\S+') | grep -oP 'src \K\S+')

Check warning on line 45 in scripts/build-image.sh

View workflow job for this annotation

GitHub Actions / unit-tests / Shell scripts lint

Quote this to prevent word splitting.
define private-ips = { 10.0.0.0/8, 127.0.0.1/8, 172.16.0.0/12, 192.168.0.0/16 }
table ip aproxy
Expand All @@ -57,17 +57,16 @@ table ip aproxy {
ip daddr != \$private-ips tcp dport { 80, 443 } counter dnat to \$default-ip:8443
}
}
EOF'
EOF

# Download and verify checksum of yq
/snap/bin/lxc exec runner -- wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64
/snap/bin/lxc exec runner -- wget https://github.com/mikefarah/yq/releases/latest/download/checksums
/snap/bin/lxc exec runner -- wget https://github.com/mikefarah/yq/releases/latest/download/checksums_hashes_order
/snap/bin/lxc exec runner -- wget https://github.com/mikefarah/yq/releases/latest/download/extract-checksum.sh
/snap/bin/lxc exec runner -- sh -c 'bash extract-checksum.sh SHA-256 yq_linux_amd64 | awk '{print $2,$1}' | sha256sum -c | grep OK'
/snap/bin/lxc exec runner -- mv yq_linux_amd64 /usr/local/bin/yq
/snap/bin/lxc exec runner -- chmod a+x /usr/local/bin/yq
/snap/bin/lxd exec runner -- rm checksums checksums_hashes_order extract-checksum.sh
/usr/bin/wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64
/usr/bin/wget https://github.com/mikefarah/yq/releases/latest/download/checksums
/usr/bin/wget https://github.com/mikefarah/yq/releases/latest/download/checksums_hashes_order
/usr/bin/wget https://github.com/mikefarah/yq/releases/latest/download/extract-checksum.sh
/usr/bin/bash extract-checksum.sh SHA-256 yq_linux_amd64 | /usr/bin/awk '{print $2,$1}' | /usr/bin/sha256sum -c | /usr/bin/grep OK

/snap/bin/lxc file push yq_linux_amd64 runner/usr/bin/yq --mode +x

/snap/bin/lxc publish runner --alias runner --reuse -f
/snap/bin/lxc image export runner ./runner-image --vm

0 comments on commit b13b401

Please sign in to comment.