Execute retry code in new transaction #673
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: Auto-CI-To-DockerHub | |
# Controls when the workflow will run | |
on: | |
# Triggers the workflow on push or pull request events but only for the master branch | |
push: | |
branches: | |
- master | |
- develop | |
- "*.*" | |
tags: | |
- '*' | |
paths-ignore: | |
- '**.md' | |
# pull_request: | |
# branches: | |
# - master | |
# - "*.*" | |
# paths-ignore: | |
# - '**.md' | |
jobs: | |
build-prod: | |
runs-on: ubuntu-latest | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- name: Check Out Repo | |
uses: actions/checkout@v2 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v1 | |
# Build cache reduces the build time. For this, use of GitHub cache. | |
- name: Cache Docker layers | |
uses: actions/cache@v2 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-buildx- | |
# Get current branch name | |
- name: Extract branch name | |
id: extract_branch | |
shell: bash | |
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF_NAME})" | |
# Determine a tag for new image | |
- name: Set Image Tag | |
id: image_tag | |
env: | |
GIT_BRANCH: ${{ steps.extract_branch.outputs.branch }} | |
run: | | |
if ${{ env.GIT_BRANCH == 'master' }} | |
then | |
echo "IMAGE_TAG=latest" >> $GITHUB_ENV | |
echo "IMAGE_TAG=latest" | |
elif ${{ env.GIT_BRANCH == 'develop' }} | |
then | |
echo "IMAGE_TAG=dev-latest" >> $GITHUB_ENV | |
echo "IMAGE_TAG=dev-latest" | |
else | |
echo "IMAGE_TAG=${GIT_BRANCH}" >> $GITHUB_ENV | |
echo "IMAGE_TAG=${GIT_BRANCH}" | |
fi | |
# Build and push an image | |
- name: Build and Push | |
id: docker_build | |
uses: docker/build-push-action@v2 | |
with: | |
context: ./ | |
build-args: | | |
BUILD_NUMBER=${{ github.sha }} | |
file: ./Dockerfile | |
builder: ${{ steps.buildx.outputs.name }} | |
push: true | |
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/wildfly-meveo:${{ env.IMAGE_TAG }} | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,dest=/tmp/.buildx-cache | |
- name: Image digest | |
run: echo ${{ steps.docker_build.outputs.digest }} | |
build-dev: | |
runs-on: ubuntu-latest | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- name: Check Out Repo | |
uses: actions/checkout@v2 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v1 | |
# Build cache reduces the build time. For this, use of GitHub cache. | |
- name: Cache Docker layers | |
uses: actions/cache@v2 | |
with: | |
path: /tmp/.buildx-dev-cache | |
key: ${{ runner.os }}-buildx-dev-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-buildx-dev- | |
# Get current branch name | |
- name: Extract branch name | |
id: extract_branch | |
shell: bash | |
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF_NAME})" | |
# Determine a tag for new image | |
- name: Set Image Tag | |
id: image_tag | |
env: | |
GIT_BRANCH: ${{ steps.extract_branch.outputs.branch }} | |
run: | | |
if ${{ env.GIT_BRANCH == 'master' }} | |
then | |
echo "IMAGE_TAG=latest" >> $GITHUB_ENV | |
echo "IMAGE_TAG=latest" | |
elif ${{ env.GIT_BRANCH == 'develop' }} | |
then | |
echo "IMAGE_TAG=dev-latest" >> $GITHUB_ENV | |
echo "IMAGE_TAG=dev-latest" | |
else | |
echo "IMAGE_TAG=${GIT_BRANCH}" >> $GITHUB_ENV | |
echo "IMAGE_TAG=${GIT_BRANCH}" | |
fi | |
- name: Build and Push | |
id: docker_build_dev | |
uses: docker/build-push-action@v2 | |
with: | |
context: ./ | |
file: ./Dockerfile.dev | |
builder: ${{ steps.buildx.outputs.name }} | |
push: true | |
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/meveo-dev:${{ env.IMAGE_TAG }} | |
cache-from: type=local,src=/tmp/.buildx-dev-cache | |
cache-to: type=local,dest=/tmp/.buildx-dev-cache | |
- name: Image digest | |
run: echo ${{ steps.docker_build_dev.outputs.digest }} |