Skip to content

Update CI and fix PR #26

Update CI and fix PR

Update CI and fix PR #26

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]
with:
fetch-depth: 0
#- name: Set base branch
# id: base_branch
# run: echo "::set-output name=base::$(git merge-base HEAD ${{ github.event.before }})"
- name: Add origin remote
id: main-remote
run: git fetch origin main:refs/remotes/origin/main
- name: Add origin new
id: main-new
run: git rev-list --count origin/main..$(git branch --show-current)
- name: Check Dockerfile changes
id: check
run: echo "::set-output name=changed::$(if git diff --name-only remotes/origin/${{ github.base_ref }}..remotes/origin/${{ github.head_ref }} | 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' }}

Check failure on line 73 in .github/workflows/ci.yml

View workflow run for this annotation

GitHub Actions / CI

Invalid workflow file

The workflow is not valid. .github/workflows/ci.yml (Line: 73, Col: 17): Unexpected symbol: '='. Located at position 19 within expression: github.event_name = 'pull_request'