Run publish CI actions only on main repo (#6592)

* only run if in an inventree org repo

* only sign into docker hub if username set

* use repo name for ghcr name

* renmae to not cause confusion

* rename vars

* use seperate step

* disable a bunch of stuff for testing

* use echo instead

* Revert "disable a bunch of stuff for testing"

This reverts commit 0ab5ff6d6d868ed06c67188cc429de2a50671931.
This commit is contained in:
Matthias Mair 2024-03-21 23:08:24 +01:00 committed by GitHub
parent e551e2e753
commit 15388d3dc3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 3 deletions

View File

@ -128,8 +128,16 @@ jobs:
- name: Set up cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@11086d25041f77fe8fe7b9ea4e48e3b9192b8f19 # pin@v3.1.2
- name: Check if Dockerhub login is required
id: docker_login
run: |
if [ -z "${{ secrets.DOCKER_USERNAME }}" ]; then
echo "skip_dockerhub_login=true" >> $GITHUB_ENV
else
echo "skip_dockerhub_login=false" >> $GITHUB_ENV
fi
- name: Login to Dockerhub
if: github.event_name != 'pull_request'
if: github.event_name != 'pull_request' && steps.docker_login.outputs.skip_dockerhub_login != 'true'
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # pin@v3.0.0
with:
username: ${{ secrets.DOCKER_USERNAME }}
@ -150,7 +158,7 @@ jobs:
with:
images: |
inventree/inventree
ghcr.io/inventree/inventree
ghcr.io/${{ github.repository }}
- name: Push Docker Images
id: push-docker

View File

@ -182,7 +182,7 @@ jobs:
name: Push new schema
runs-on: ubuntu-20.04
needs: [paths-filter, schema]
if: needs.schema.result == 'success' && github.ref == 'refs/heads/master' && needs.paths-filter.outputs.api == 'true'
if: needs.schema.result == 'success' && github.ref == 'refs/heads/master' && needs.paths-filter.outputs.api == 'true' && github.repository_owner == 'inventree'
env:
version: ${{ needs.schema.outputs.version }}