Docker #260
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Docker | |
on: | |
push: | |
# Publish `master` as Docker `latest` image. | |
branches: | |
- master | |
# Publish `vfrinx2.0.3` tags as releases. | |
tags: | |
- vfrinx2* | |
workflow_dispatch: | |
env: | |
# TODO: Change variable to your image's name. | |
IMAGE_NAME: frinx/conductor-server | |
jobs: | |
# Push image to GitHub Packages. | |
# See also https://docs.docker.com/docker-hub/builds/ | |
build-image-v2: | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres | |
ports: | |
- 5432:5432 | |
env: | |
POSTGRES_PASSWORD: postgres | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
submodules: recursive | |
#### Docker build #### | |
- name: Build image | |
run: docker build . --file docker/server/Dockerfile --tag $IMAGE_NAME:latest --build-arg git_commit=$(git rev-parse HEAD) | |
- name: Log into docker hub | |
run: echo "${{ secrets.DOCKER_HUB_PASSWORD }}" | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin | |
#### Docker latest publish #### | |
# - name: Push latest image | |
# if: startsWith(github.ref, 'refs/tags/master') | |
# run: docker push $IMAGE_NAME:latest | |
#### Docker release publish #### | |
- name: Get the version | |
if: startsWith(github.ref, 'refs/tags/vfrinx2') | |
id: get_version | |
run: echo ::set-output name=VERSION::$(echo $GITHUB_REF | cut -d / -f 3 | sed -e 's/^vfrinx//') | |
- name: Push release image | |
if: startsWith(github.ref, 'refs/tags/vfrinx2') | |
run: docker tag $IMAGE_NAME:latest $IMAGE_NAME:${{ steps.get_version.outputs.VERSION }} | |
- name: Push release image | |
if: startsWith(github.ref, 'refs/tags/vfrinx2') | |
run: docker push $IMAGE_ID:${{ steps.get_version.outputs.VERSION }} | |
#### OpenAPI publish #### | |
- name: Run conductor image | |
run: docker run -d --network "$(docker network ls --filter type=custom --format '{{ .Name }}')" --publish 8080:8080 $IMAGE_NAME:latest | |
- name: Get conductor openapi spec | |
run: sleep 15 && curl http://localhost:8080/v3/api-docs -o openapi.json | |
- name: Check out swagger_docs branch | |
uses: actions/checkout@v4 | |
with: | |
ref: swagger_docs | |
path: swagger_docs | |
fetch-depth: 2 | |
- name: Commit swagger latest | |
if: startsWith(github.ref, 'refs/tags/swagger_publish') | |
run: | | |
git_hash=$(git rev-parse --short "$GITHUB_SHA") | |
git_branch=${GITHUB_REF#refs/heads/} | |
cp openapi.json swagger_docs/latest.json | |
pushd swagger_docs || exit 1 | |
git config -l --show-scope | |
git config --global user.email "[email protected]" | |
git config --global user.name "FRINXrepo" | |
git add latest.json | |
(git commit -am "Updated swagger for ${git_branch}/${git_hash}" && git push) || echo "Nothing to commit" | |
git push | |
popd | |
- name: Commit swagger production | |
if: startsWith(github.ref, 'refs/tags/vfrinx2') | |
run: | | |
git_hash=$(git rev-parse --short "$GITHUB_SHA") | |
git_branch=${GITHUB_REF#refs/heads/} | |
cp openapi.json swagger_docs/production.json | |
cp openapi.json swagger_docs/v${{ steps.get_version.outputs.VERSION }}.json | |
pushd swagger_docs || exit 1 | |
git config -l --show-scope | |
git config --global user.email "[email protected]" | |
git config --global user.name "FRINXrepo" | |
git add production.json v${{ steps.get_version.outputs.VERSION }}.json | |
(git commit -am "Updated swagger for ${git_branch}/${git_hash}" && git push) || echo "Nothing to commit" | |
popd |