mirror of
https://github.com/joaovitoriasilva/endurain.git
synced 2026-01-10 08:17:59 -05:00
50 lines
1.6 KiB
YAML
50 lines
1.6 KiB
YAML
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
|
|
echo "IMAGE_TAG=${IMAGE_TAG}"
|
|
docker build . --file Dockerfile --tag ${{ github.repository }}:$IMAGE_TAG
|
|
echo "IMAGE_TAG=${IMAGE_TAG}" >> $GITHUB_ENV
|
|
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch'
|
|
|
|
|
|
- name: Push the Docker image to GHCR
|
|
if: success() && (github.event_name == 'release' || github.event_name == 'workflow_dispatch')
|
|
run: |
|
|
echo "github.event_name=${{ github.event_name }}"
|
|
echo "IMAGE_TAG=${IMAGE_TAG}"
|
|
echo "github.repository=${{ github.repository }}"
|
|
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
|