Skip to content

Commit

Permalink
Fix CI triggering on main branch
Browse files Browse the repository at this point in the history
- CI was triggering on main branch instead of
  • Loading branch information
gbdlin committed Sep 3, 2023
1 parent 49de9a8 commit bf858fd
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 10 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@ on:

env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
REGISTRY: "${{ github.event_name == 'pull_request' && 'localhost:5000' || 'ghcr.io' }}"
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}

jobs:
docker-build:
runs-on: ubuntu-latest
services:
registry:
image: registry:2
ports:
- 5000:5000
permissions:
contents: read
packages: write
Expand All @@ -24,6 +29,8 @@ jobs:
# Workaround: https://github.com/docker/build-push-action/issues/461
- name: Setup Docker buildx
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf
with:
driver-opts: network=host

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
Expand Down Expand Up @@ -69,5 +76,5 @@ jobs:
id: set
shell: bash
run: |
name="ghcr.io/${{ github.repository }}:sha-${{ github.sha }}"
name="${{ env.REGISTRY }}/${{ github.repository }}:sha-${{ github.sha }}"
echo "image=${name,,}" >> $GITHUB_OUTPUT
22 changes: 15 additions & 7 deletions .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
name: Checks

on:
pull_request_target:
pull_request:
branches:
- "main"

env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}

defaults:
run:
working-directory: "/app"
Expand All @@ -24,6 +18,11 @@ jobs:
runs-on: ubuntu-latest
needs:
- build
services:
registry:
image: registry:2
ports:
- 5000:5000
container:
image: ${{ needs.build.outputs.image }}
credentials:
Expand All @@ -33,17 +32,26 @@ jobs:
matrix:
linter: [flake8, isort, black, mypy]
steps:
- name: "Checkout"
uses: "actions/checkout@v3"
- run: "make lint/${{ matrix.linter }}"

test:
runs-on: ubuntu-latest
needs:
- build
- lint
services:
registry:
image: registry:2
ports:
- 5000:5000
container:
image: ${{ needs.build.outputs.image }}
credentials:
username: ${{ github.actor }}
password: ${{ secrets.github_token }}
steps:
- name: "Checkout"
uses: "actions/checkout@v3"
- run: "make test"
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ lint/black:
black --check --diff plugin_store/ tests/

lint/mypy:
PYTHON_PATH=/app/plugin_store mypy plugin_store/ tests/
PYTHON_PATH=./plugin_store mypy plugin_store/ tests/

lint: lint/black lint/isort lint/flake8 lint/mypy

Expand Down

0 comments on commit bf858fd

Please sign in to comment.