Skip to content

test new ci

test new ci #16

Workflow file for this run

name: CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
check-dockerfile-changes:
name: Check Dockerfile changes
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/[email protected]
- name: Set base branch
id: base_branch
run: echo "::set-output name=base::$(git merge-base HEAD ${{ github.event.before }})"
- name: Check Dockerfile changes
id: check
run: echo "::set-output name=changed::$(if git diff --name-only ${{ steps.base_branch.outputs.base }} ${{ github.sha }} | grep -q 'Dockerfile'; then echo true; else echo false; fi)"
build-and-push-to-registry:
needs: check-dockerfile-changes
name: Push Docker image to Docker HUB
runs-on: ubuntu-latest
if: needs.check-dockerfile-changes.outputs.changed == 'true'
env:
REPO: ${{ secrets.DOCKER_REPO }}
steps:
- name: Checkout repo
uses: actions/[email protected]
- name: Log in to Docker Hub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Set subfolder name
run: echo "::set-env name=SUBFOLDER::$(dirname $(find . -name Dockerfile))"
- name: Docker Metadata action
id: meta
uses: docker/[email protected]
with:
images: |
${{ secrets.DOCKER_REPO }}/${{ env.SUBFOLDER}}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{major}}.{{minor}}.{{patch}}
- name: Build and push Docker images
uses: docker/[email protected]
with:
file: ${{ env.SUBFOLDER }}/Dockerfile
context: .
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push: ${{ github.event_name != 'pull_request' }}