Skip to content

Commit

Permalink
Merge pull request #24 from BigBang1112/add-docker-publish
Browse files Browse the repository at this point in the history
Create docker-publish.yml
  • Loading branch information
BigBang1112 authored Aug 25, 2024
2 parents be97ab0 + cfc83b8 commit 37610f6
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Docker Image Publish

on:
workflow_dispatch:

env:
BUILD_DIR: .
IMAGE_NAME: nations-converter-web

permissions:
packages: write

jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Set lowercase repository_owner and tag_name without v
run: |
echo "OWNER_LC=${OWNER,,}" >>${GITHUB_ENV}
echo "VERSION=${TAG#v}" >>${GITHUB_ENV}
env:
OWNER: '${{ github.repository_owner }}'
TAG: '${{ github.event.release.tag_name }}'

- name: Build Docker Image
run: |
cd $BUILD_DIR
docker build . -f Src/NationsConverterWeb/NationsConverterWeb/Dockerfile -t ghcr.io/$OWNER_LC/$IMAGE_NAME -t ${{ secrets.DOCKER_USERNAME }}/$IMAGE_NAME
- name: Push the Docker image to ghcr.io
run: |
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u USERNAME --password-stdin
docker push ghcr.io/$OWNER_LC/$IMAGE_NAME
- name: Push the Docker image to hub.docker.com
run: |
echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
docker push ${{ secrets.DOCKER_USERNAME }}/$IMAGE_NAME

0 comments on commit 37610f6

Please sign in to comment.