Answer the question
In order to leave comments, you need to log in
How to do github CI/CD on VPS for node.js?
Good afternoon! I'm trying to make ci/cd for github. I googled articles, there are very few sensible ones, and some are already outdated and do not work. Stuck in deploy on VPS.
How it is implemented now:
1) Written .github/workflows/push.yaml
# Создаем тригер когда кто-то пушит код в репозиторий
on: push
name: npm build, lint, test and publish
# Создаем задачи для сборки проекта и запуска на ubuntu-latest.
# Каждая задача будет запущенна в новой копии приложения на виртуальном сервереt..
jobs:
build-and-publish:
name: build and publish
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions/[email protected]
with:
node-version: '10.x'
- run: npm install
- run: npm test
# Создаем Docker образ
- name: Publish to Docker Repository
uses: elgohr/[email protected]
with:
name: vaflya/project
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
run: docker build -t back .
FROM node
WORKDIR /
COPY . .
RUN npm install
EXPOSE 3000
ENTRYPOINT ["npm", "start"]
Answer the question
In order to leave comments, you need to log in
You are cooking the cat wrong.
Point three must be done passively, that is, enable integration with github in docker hub and then you can create "Automated build". Each push will create an image.
The script below can check if the image exists:
function docker_tag_exists() {
curl --silent -f -lSL https://index.docker.io/v1/repositories/$1/tags/$2 > /dev/null
}
if docker_tag_exists library/nginx 1.7.5; then
echo exist
else
echo not exists
fi
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question