Skip to content

Build and Push Docker image to GitLab Registry #12

Build and Push Docker image to GitLab Registry

Build and Push Docker image to GitLab Registry #12

name: Build and Push Docker image to GitLab Registry
on:
workflow_dispatch:
permissions:
contents: read
packages: read
env:
IMAGE_NAME: inocs-sum-odp-webapp
REGISTRY: ${{ secrets.GITLAB_REGISTRY }}
PROJECT_PATH: ${{ vars.GITLAB_PROJECT_PATH }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitLab Container Registry
run: echo "${{ secrets.GITLAB_PASSWORD }}" | docker login ${{ env.REGISTRY }} -u ${{ secrets.GITLAB_USER }} --password-stdin
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: true
tags: |
${{ env.REGISTRY }}/${{ env.PROJECT_PATH }}/${{ env.IMAGE_NAME }}:0.0.2
- name: Logout
run: docker logout ${{ env.REGISTRY }}