Skip to content

Commit

Permalink
Create docker-image.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
kazami139 authored and GitHub Enterprise committed Feb 11, 2023
1 parent 5bac20f commit 2033602
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: EOEFANS API Docker Image CI

on:
push:
branches: [ "main" ]
pull_request:
types: [synchronize, closed]
branches: [ "main" ]

env:
IMAGE_REGISTRY: "containers.vlink.dev"
DOCKERFILE_PATH: "/builder/api/Dockerfile"
IMAGE_REPO: ${{ github.repository }}
IMAGE_NAME: "eoefans-api"
# IMAGE_TAG: "" #we get tag using the action down below

jobs:

build:

runs-on: [ self-hosted, Linux ]

steps:
- uses: actions/checkout@v3

- name: Get tag
id: tag
uses: dawidd6/action-get-tag@v1
- run: |
echo "IMAGE_TAG=${{steps.tag.outputs.tag}}" >> $GITHUB_ENV
echo $IMAGE_TAG
- name: Log in to GitHub Docker Registry
uses: docker/login-action@v2
with:
registry: containers.vlink.dev
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build the Docker image
run: docker build . --file ${{ DOCKERFILE_PATH }} --tag ${{ IMAGE_REPO }}}/${{ IMAGE_NAME }}:${{ IAMGE_TAG }}

- name: Build and push Docker image with version number
uses: docker/build-push-action@v4
with:
push: true
tags: |
${{ IMAGE_REPO }}}/${{ IMAGE_NAME }}:${{ IAMGE_TAG }}
- name: Retag the image to latest tag
run: docker tag ${{ IMAGE_REPO }}}/${{ IMAGE_NAME }}:${{ IAMGE_TAG }} ${{ IMAGE_REPO }}}/${{ IMAGE_NAME }}:latest


- name: Build and push Docker image with latest
uses: docker/build-push-action@v4
with:
push: true
tags: |
${{ IMAGE_REPO }}}/${{ IMAGE_NAME }}:latest

0 comments on commit 2033602

Please sign in to comment.