Merge pull request 'DRY: re-use lxc-helpers' (#18) from earl-warren/setup-forgejo:wip-helpers into main

Reviewed-on: https://code.forgejo.org/actions/setup-forgejo/pulls/18
Reviewed-by: dachary <dachary@noreply.code.forgejo.org>
This commit is contained in:
earl-warren 2023-05-16 23:41:16 +00:00
commit 9c653c5938
7 changed files with 19 additions and 26 deletions

View file

@ -11,6 +11,8 @@ jobs:
runs-on: self-hosted runs-on: self-hosted
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
with:
submodules: 'true'
- run: | - run: |
set -x set -x
./forgejo-dependencies.sh install_docker ./forgejo-dependencies.sh install_docker

View file

@ -4,6 +4,8 @@ jobs:
runs-on: self-hosted runs-on: self-hosted
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
with:
submodules: 'true'
- run: | - run: |
set -x set -x
LXC_IP_PREFIX=10.0.9 ./forgejo-dependencies.sh LXC_IP_PREFIX=10.0.9 ./forgejo-dependencies.sh

3
.gitmodules vendored Normal file
View file

@ -0,0 +1,3 @@
[submodule "lxc-helpers"]
path = lxc-helpers
url = https://code.forgejo.org/forgejo/lxc-helpers

View file

@ -3,35 +3,18 @@
set -x set -x
source $(dirname $0)/lxc-helpers/enough-lxc-helpers.sh
: ${LXC_IP_PREFIX:=10.0.8} : ${LXC_IP_PREFIX:=10.0.8}
function install_docker() { function install_docker() {
if ! systemctl is-active --quiet docker; then if ! systemctl is-active --quiet docker; then
echo deb http://deb.debian.org/debian bullseye-backports main | tee /etc/apt/sources.list.d/backports.list && apt-get update lxc_install_docker_inside
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends --quiet -y -t bullseye-backports git docker.io
fi
}
function install_lxc() {
if ! systemctl is-active --quiet lxc-net; then
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y -qq make git libvirt0 libpam-cgfs bridge-utils uidmap dnsmasq-base dnsmasq dnsmasq-utils qemu-user-static
systemctl disable --now dnsmasq
apt-get install -y -qq lxc
systemctl stop lxc-net
cat >> /etc/default/lxc-net <<EOF
LXC_ADDR="$LXC_IP_PREFIX.1"
LXC_NETMASK="255.255.255.0"
LXC_NETWORK="$LXC_IP_PREFIX.0/24"
LXC_DHCP_RANGE="$LXC_IP_PREFIX.2,$LXC_IP_PREFIX.254"
LXC_DHCP_MAX="253"
EOF
systemctl start lxc-net
fi fi
} }
function install_other() { function install_other() {
local packages="sudo" local packages="sudo git"
if ! which $packages ; then if ! which $packages ; then
apt-get install -y -qq $packages apt-get install -y -qq $packages
fi fi
@ -40,7 +23,7 @@ function install_other() {
function setup() { function setup() {
install_other install_other
install_docker install_docker
install_lxc lxc_install_lxc_inside $LXC_IP_PREFIX
} }
"${@:-setup}" "${@:-setup}"

View file

@ -13,8 +13,8 @@ function dependency_go() {
if ! which go > /dev/null ; then if ! which go > /dev/null ; then
apt-get update apt-get update
apt-get install -y -qq wget tar apt-get install -y -qq wget tar
wget https://go.dev/dl/go1.20.3.linux-amd64.tar.gz wget --quiet https://go.dev/dl/go1.20.4.linux-amd64.tar.gz
tar zxf go1.20.3.linux-amd64.tar.gz tar zxf go1.20.4.linux-amd64.tar.gz
export PATH=$PATH:$(pwd)/go/bin export PATH=$PATH:$(pwd)/go/bin
fi fi
} }
@ -138,10 +138,10 @@ function push_self_action() {
local tag="$4" local tag="$4"
local dir="$DIR/self" local dir="$DIR/self"
git clone . $dir git clone --recurse-submodules . $dir
( (
cd $dir cd $dir
rm -fr .forgejo .git rm -fr .forgejo .git lxc-helpers/.git
git init git init
git checkout -b main git checkout -b main
git remote add origin "$url/$owner/$self_action" git remote add origin "$url/$owner/$self_action"

1
lxc-helpers Submodule

@ -0,0 +1 @@
Subproject commit 0e3a7b3f4835b45cc3758f974f09819c923b2398

View file

@ -10,6 +10,8 @@ jobs:
echo +++++++++++++++++++++++++++++++++++++++++++ echo +++++++++++++++++++++++++++++++++++++++++++
echo about to actions/checkout@v3 for SELF@vTest echo about to actions/checkout@v3 for SELF@vTest
- uses: actions/checkout@v3 - uses: actions/checkout@v3
with:
submodules: 'true'
- id: forgejo - id: forgejo
uses: SELF@vTest uses: SELF@vTest
with: with: