init docker build script
This commit is contained in:
commit
1558e213d2
2 files changed
+47
No files matched your search
@@ -0,0 +1,42 @@
|
||||
name: Build and Push Docker Image
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Login to Registry
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
registry: eiche:3000
|
||||
username: ${{ secrets.REGISTRY_USER }}
|
||||
password: ${{ secrets.REGISTRY_PASSWORD }}
|
||||
|
||||
- name: Build Docker Image
|
||||
env:
|
||||
REGESTRY: eiche:3000
|
||||
IMAGE: ${{ GITHUB_REPOSITORY }}
|
||||
run: |
|
||||
# Build the image with the commit hash tag
|
||||
docker build -t ${REGISTRY}/${IMAGE}:${GITHUB_RUN_NUMBER} .
|
||||
|
||||
# Tag the same image as "latest"
|
||||
docker tag ${REGISTRY}/${IMAGE}:${GITHUB_RUN_NUMBER} ${REGISTRY}/${IMAGE}:latest
|
||||
|
||||
- name: Push Docker Images
|
||||
env:
|
||||
REGESTRY: eiche:3000
|
||||
IMAGE: ${{ GITHUB_REPOSITORY }}
|
||||
run: |
|
||||
docker push ${REGISTRY}/${IMAGE}:${GITHUB_RUN_NUMBER}
|
||||
docker push ${REGISTRY}/${IMAGE}:latest
|
||||
|
||||
- name: Log out from registry
|
||||
if: always()
|
||||
run: docker logout eiche:3000
|
||||