mirror of
https://github.com/joaovitoriasilva/endurain.git
synced 2026-01-09 15:57:59 -05:00
Create docker-image.yml
This commit is contained in:
committed by
GitHub
parent
32d1e79c57
commit
281bafd371
44
.github/workflows/docker-image.yml
vendored
Normal file
44
.github/workflows/docker-image.yml
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
name: Create API Docker image on new release or using manual trigger
|
||||
|
||||
on:
|
||||
#push:
|
||||
# branches: [ "master" ]
|
||||
#pull_request:
|
||||
# branches: [ "master" ]
|
||||
workflow_dispatch:
|
||||
release:
|
||||
types:
|
||||
- created
|
||||
|
||||
jobs:
|
||||
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set release version or use default
|
||||
run: echo "RELEASE_VERSION=${{ github.event.release.tag_name }}" >> $GITHUB_ENV
|
||||
if: github.event_name == 'release'
|
||||
|
||||
- name: Build the Docker image
|
||||
run: |
|
||||
if [ "${{ github.event_name }}" == 'workflow_dispatch' ]; then
|
||||
IMAGE_TAG="dev_$(date +"%Y%m%d")"
|
||||
else
|
||||
IMAGE_TAG="${{ github.event.release.tag_name }}"
|
||||
fi
|
||||
docker build . --file Dockerfile --tag ${{ github.repository }}:$IMAGE_TAG
|
||||
#run: docker build . --file Dockerfile --tag ${{ github.repository }}:latest
|
||||
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.action == 'workflow_dispatch')
|
||||
|
||||
- name: Push the Docker image to GHCR
|
||||
if: success() && (github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.action == 'workflow_dispatch'))
|
||||
run: |
|
||||
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.repository_owner }} --password-stdin
|
||||
IMAGE_NAME="ghcr.io/${{ github.repository }}"
|
||||
docker tag ${{ github.repository }}:$IMAGE_TAG $IMAGE_NAME:$IMAGE_TAG
|
||||
docker push $IMAGE_NAME:$IMAGE_TAG
|
||||
Reference in New Issue
Block a user