Skip to content

Merge pull request #58 from Alanimdeo/dependabot/npm_and_yarn/nanoid-… #66

Merge pull request #58 from Alanimdeo/dependabot/npm_and_yarn/nanoid-…

Merge pull request #58 from Alanimdeo/dependabot/npm_and_yarn/nanoid-… #66

Workflow file for this run

name: Docker Build and Publish
on:
push:
branches:
- main
jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set environment variables
run: |
VERSION=$(node -p "require('./backend/package.json').version")
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "MAJOR_VERSION=$(echo $VERSION | cut -d '.' -f -1)" >> $GITHUB_ENV
echo "MINOR_VERSION=$(echo $VERSION | cut -d '.' -f -2)" >> $GITHUB_ENV
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build Docker image
run: |
docker build -t alanimdeo/conveyor:latest -t alanimdeo/conveyor:$VERSION -t alanimdeo/conveyor:$MAJOR_VERSION -t alanimdeo/conveyor:$MINOR_VERSION .
- name: Push Docker image to Docker Hub
run: |
docker push alanimdeo/conveyor:$MAJOR_VERSION
docker push alanimdeo/conveyor:$MINOR_VERSION
docker push alanimdeo/conveyor:$VERSION
docker push alanimdeo/conveyor:latest
- name: Push Docker image to GitHub Container Registry
run: |
docker tag alanimdeo/conveyor:$MAJOR_VERSION ghcr.io/alanimdeo/conveyor:$MAJOR_VERSION
docker tag alanimdeo/conveyor:$MINOR_VERSION ghcr.io/alanimdeo/conveyor:$MINOR_VERSION
docker tag alanimdeo/conveyor:$VERSION ghcr.io/alanimdeo/conveyor:$VERSION
docker tag alanimdeo/conveyor:latest ghcr.io/alanimdeo/conveyor:latest
docker push ghcr.io/alanimdeo/conveyor:$MAJOR_VERSION
docker push ghcr.io/alanimdeo/conveyor:$MINOR_VERSION
docker push ghcr.io/alanimdeo/conveyor:$VERSION
docker push ghcr.io/alanimdeo/conveyor:latest