83 lines
3.7 KiB
YAML
83 lines
3.7 KiB
YAML
name: Install
|
|
run-name: ${{ gitea.actor }} is intall Actions 🚀
|
|
on: [push]
|
|
jobs:
|
|
install:
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: ubuntu-latest # [ubuntu-latest, macos-latest, windows-latest]
|
|
name: Cargo install on ubuntu-latest
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }}
|
|
KUBECONFIG: "/tmp/.kubeconfig"
|
|
RUSTUP_HOME: "/toolcache/rust/.rustup"
|
|
CARGO_HOME: "/toolcache/rust/.cargo"
|
|
steps:
|
|
- name: Init job triggered by event
|
|
run: echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event "
|
|
- name: Workspace
|
|
run: echo "🔎 Branch name ${{ gitea.ref }} from repository ${{ gitea.repository }}."
|
|
# ls ${{ gitea.workspace }}
|
|
- name: Check out repository code
|
|
uses: actions/checkout@v3
|
|
with:
|
|
persist-credentials: true
|
|
# submodules: 'recursive'
|
|
# Defs in https://github.com/actions/checkout
|
|
#run: echo "💡 The ${{ gitea.repository }} repository has been cloned to the runner."
|
|
- name: Submodules update
|
|
run: |
|
|
cd ${{ gitea.workspace }}
|
|
while true; do sleep 50 ; done
|
|
#git submodule update --init --recursive
|
|
- name: Install Rust
|
|
run: |
|
|
printf "\n\t🐋 Installing dependencies 🐋\t\n"
|
|
apt-get -yq update
|
|
apt-get -yq install build-essential llvm libssl-dev
|
|
if [ -x "${CARGO_HOME}/bin/cargo" ] ; then
|
|
source "${CARGO_HOME}/env"
|
|
else
|
|
printf "\n\t🐋 Installing Rust 🐋\t\n"
|
|
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain=stable --profile=minimal
|
|
source "${CARGO_HOME}/env"
|
|
printf "\n\t🐋 Installing Rust components 🐋\t\n"
|
|
rustup component add rustfmt clippy
|
|
fi
|
|
printf "\n\t🐋 Installed CARGO 🐋\t\n"
|
|
cargo -V
|
|
printf "\n\t🐋 Installed RUSTC 🐋\t\n"
|
|
rustc -V
|
|
# printf "\n\t🐋 Installed RUSTUP 🐋\t\n"
|
|
# rustup -V
|
|
- name: Rust build
|
|
run: |
|
|
source "${CARGO_HOME}/env"
|
|
while true; do sleep 20; done
|
|
#cd ${{ gitea.workspace }}
|
|
#cargo build
|
|
#ls -l target/debug
|
|
- name: Install kubectl
|
|
run: |
|
|
OS="$(uname | tr '[:upper:]' '[:lower:]')"
|
|
ARCH="$(uname -m | sed -e 's/x86_64/amd64/' -e 's/\(arm\)\(64\)\?.*/\1\2/' -e 's/aarch64$/arm64/')"
|
|
apt-get update
|
|
apt-get install ca-certificates
|
|
update-ca-certificates
|
|
curl -L "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/$OS/$ARCH/kubectl" -o /usr/local/bin/kubectl
|
|
[ -r "/usr/local/bin/kubectl" ] && chmod +x /usr/local/bin/kubectl
|
|
echo "${{ secrets.KUBE_CONFIG }}" | base64 -d > $KUBECONFIG
|
|
- name: Run K8s JOB
|
|
run: |
|
|
echo "${{ vars.K8_JOB }}" | sed "s/{{KS_NAMESPACE}}/${{ vars.KS_NAMESPACE }}/g" | sed "s/{{KS_JOB_NAME}}/${{ vars.KS_JOB_NAME }}/g" > /tmp/job.yaml
|
|
if [ -n "$(kubectl get pods -n ${{ vars.KS_NAMESPACE }} | grep ${{ vars.KS_JOB_NAME }})" ]; then
|
|
kubectl delete -f /tmp/job.yaml
|
|
fi
|
|
echo "${{ vars.K8_CONFIGMAP_JOB }}" | sed "s/{{KS_NAMESPACE}}/${{ vars.KS_NAMESPACE }}/g" | sed "s/{{KS_JOB_NAME}}/${{ vars.KS_JOB_NAME }}/g"> /tmp/config_job.yaml
|
|
echo "🍏 Job ${{ vars.KS_JOB_NAME }} in ${{ vars.KS_NAMESPACE }} launched."
|
|
# kubectl apply -f /tmp/config_job.yaml
|
|
# kubectl apply -f /tmp/job.yaml
|
|
# kubectl get jobs -n ${{ vars.KS_NAMESPACE }} |