84 lines
3.3 KiB
YAML
84 lines
3.3 KiB
YAML
name: 'Build docker container'
|
|
on:
|
|
push:
|
|
tags:
|
|
- '*'
|
|
workflow_dispatch:
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
defaults:
|
|
run:
|
|
working-directory: ${{ GITHUB_WORKSPACE }}
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
- name: Install Docker
|
|
run: |
|
|
echo "Checking docker installation"
|
|
if command -v docker &> /dev/null; then
|
|
echo "Docker installation found"
|
|
else
|
|
echo "Docker installation not found. Docker will be installed"
|
|
curl -fsSL https://get.docker.com | sh
|
|
fi
|
|
- name: Install npm dependencies
|
|
run: |
|
|
echo "Installing fetch"
|
|
install_node=$false
|
|
if ! command -v node &> /dev/null; then
|
|
echo "No version of NodeJS detected"
|
|
install_node=true
|
|
else
|
|
node_version=$(node -v)
|
|
node_version=${node_version:1} # Remove 'v' at the beginning
|
|
node_version=${node_version%\.*} # Remove trailing ".*".
|
|
node_version=${node_version%\.*} # Remove trailing ".*".
|
|
node_version=$(($node_version)) # Convert the NodeJS version number from a string to an integer.
|
|
if [ $node_version -lt 24 ]; then
|
|
echo "node version : " $node_version
|
|
echo $"removing outdated npm version"
|
|
install_node=true
|
|
apt-get remove nodejs npm
|
|
fi
|
|
fi
|
|
|
|
if $install_node; then
|
|
NODE_MAJOR=24
|
|
echo "Installing node ${NODE_MAJOR}"
|
|
if test -f /etc/apt/keyrings/nodesource.gpg; then
|
|
rm /etc/apt/keyrings/nodesource.gpg
|
|
fi
|
|
if test -f /etc/apt/sources.list.d/nodesource.list; then
|
|
rm /etc/apt/sources.list.d/nodesource.list
|
|
fi
|
|
apt-get update
|
|
apt-get install -y -q ca-certificates curl gnupg
|
|
mkdir -p /etc/apt/keyrings
|
|
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
|
|
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_${NODE_MAJOR}.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list
|
|
apt-get update
|
|
apt-get install -y -q nodejs
|
|
npm install npm --global
|
|
fi
|
|
|
|
echo "node version : " $(node -v)
|
|
|
|
echo $(npm list -g | grep -c @actions/core)
|
|
echo $(npm list -g | grep -c node-fetch)
|
|
package='node-fetch'
|
|
if [ `npm list -g | grep -c $package` -eq 0 ]; then
|
|
npm install -g $package
|
|
fi
|
|
- name: Login to DockerHub container registry
|
|
uses: https://github.com/docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
|
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
|
|
- name: Docker Hub Description
|
|
uses: peter-evans/dockerhub-description@v5
|
|
with:
|
|
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
|
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
|
|
repository: davidquinonescl/hyperion-docker
|