Update workflows to work on forks

Signed-off-by: Fred Heinecke <fred.heinecke@yahoo.com>
This commit is contained in:
Fred Heinecke 2025-04-26 22:09:40 +00:00 committed by Zoe Roux
parent 94fe79bcd1
commit 35437500ed
4 changed files with 49 additions and 23 deletions

View File

@ -22,42 +22,44 @@ jobs:
- context: ./back - context: ./back
dockerfile: Dockerfile dockerfile: Dockerfile
label: back label: back
image: zoriya/kyoo_back image: ${{ github.repository_owner }}/kyoo_back
- context: ./back - context: ./back
dockerfile: Dockerfile.migrations dockerfile: Dockerfile.migrations
label: migrations label: migrations
image: zoriya/kyoo_migrations image: ${{ github.repository_owner }}/kyoo_migrations
- context: ./api - context: ./api
dockerfile: Dockerfile dockerfile: Dockerfile
label: api label: api
image: zoriya/kyoo_api image: ${{ github.repository_owner }}/kyoo_api
- context: ./front - context: ./front
dockerfile: Dockerfile dockerfile: Dockerfile
label: front label: front
image: zoriya/kyoo_front image: ${{ github.repository_owner }}/kyoo_front
- context: ./scanner - context: ./scanner
dockerfile: Dockerfile dockerfile: Dockerfile
label: scanner label: scanner
image: zoriya/kyoo_scanner image: ${{ github.repository_owner }}/kyoo_scanner
- context: ./autosync - context: ./autosync
dockerfile: Dockerfile dockerfile: Dockerfile
label: autosync label: autosync
image: zoriya/kyoo_autosync image: ${{ github.repository_owner }}/kyoo_autosync
- context: ./transcoder - context: ./transcoder
dockerfile: Dockerfile dockerfile: Dockerfile
label: transcoder label: transcoder
image: zoriya/kyoo_transcoder image: ${{ github.repository_owner }}/kyoo_transcoder
- context: ./auth - context: ./auth
dockerfile: Dockerfile dockerfile: Dockerfile
label: auth label: auth
image: zoriya/keibi image: ${{ github.repository_owner }}/keibi
env:
DOCKERHUB_ENABLED: ${{ secrets.DOCKER_USERNAME && secrets.DOCKER_PASSWORD && 'true' || 'false' }}
name: Build ${{matrix.label}} name: Build ${{matrix.label}}
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
@ -74,7 +76,7 @@ jobs:
uses: docker/metadata-action@v5 uses: docker/metadata-action@v5
with: with:
images: | images: |
docker.io/${{matrix.image}} docker.io/${{matrix.image}},enable=${{ env.DOCKERHUB_ENABLED }}
ghcr.io/${{matrix.image}} ghcr.io/${{matrix.image}}
tags: | tags: |
type=edge type=edge
@ -94,7 +96,7 @@ jobs:
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
- name: Login to DockerHub - name: Login to DockerHub
if: env.SHOULD_PUSH == 'true' if: env.SHOULD_PUSH == 'true' && env.DOCKERHUB_ENABLED == 'true'
uses: docker/login-action@v3 uses: docker/login-action@v3
with: with:
username: ${{ secrets.DOCKER_USERNAME }} username: ${{ secrets.DOCKER_USERNAME }}
@ -124,7 +126,7 @@ jobs:
cache-to: type=gha,mode=max cache-to: type=gha,mode=max
- name: Sync README.MD - name: Sync README.MD
if: env.SHOULD_PUSH == 'true' if: env.SHOULD_PUSH == 'true' && env.DOCKERHUB_ENABLED == 'true'
uses: ms-jpq/sync-dockerhub-readme@v1 uses: ms-jpq/sync-dockerhub-readme@v1
with: with:
username: ${{ secrets.DOCKER_USERNAME }} username: ${{ secrets.DOCKER_USERNAME }}

View File

@ -32,6 +32,11 @@ jobs:
export tag=$(echo ${GITHUB_REF#refs/tags/} | sed 's/^v//') export tag=$(echo ${GITHUB_REF#refs/tags/} | sed 's/^v//')
helm package ./chart --version $tag --app-version $tag helm package ./chart --version $tag --app-version $tag
- name: Build Helm-safe repo name
run: |
REPO_NAME="$(echo "oci://ghcr.io/${GITHUB_REPOSITORY_OWNER}/helm-charts" | tr '[:upper:]' '[:lower:]')"
echo "REPO_NAME=${REPO_NAME}" >> "${GITHUB_ENV}"
- name: Push Helm Chart to GHCR - name: Push Helm Chart to GHCR
run: | run: |
helm push kyoo-*.tgz oci://ghcr.io/${{ github.repository_owner }}/helm-charts helm push kyoo-*.tgz "${REPO_NAME}"

View File

@ -15,15 +15,20 @@ jobs:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Check for EXPO_TOKEN # This is required because GHA doesn't support secrets in the `if` condition
- name: Check if Expo build is enabled
env:
IS_SECRET_SET: ${{ env.IS_EXPO_ENABLED == 'true' && 'true' || 'false' }}
run: echo "IS_EXPO_ENABLED=${IS_SECRET_SET}" >> "${GITHUB_ENV}"
- name: Log if Expo build is disabled due to fork
if: env.IS_EXPO_ENABLED != 'true'
run: | run: |
if [ -z "${{ secrets.EXPO_TOKEN }}" ]; then echo "Expo build is disabled for forks. To enable it, add an EXPO_TOKEN secret to this repository. See https://docs.expo.dev/eas-update/github-actions/ for more information."
echo "You must provide an EXPO_TOKEN secret linked to this project's Expo account in this repo's secrets. Learn more: https://docs.expo.dev/eas-update/github-actions"
exit 1
fi
- name: Setup Node - name: Setup Node
uses: actions/setup-node@v4 uses: actions/setup-node@v4
if: env.IS_EXPO_ENABLED == 'true'
with: with:
node-version: 22.x node-version: 22.x
cache: yarn cache: yarn
@ -31,34 +36,40 @@ jobs:
- name: Setup Expo - name: Setup Expo
uses: expo/expo-github-action@v8 uses: expo/expo-github-action@v8
if: env.IS_EXPO_ENABLED == 'true'
with: with:
expo-version: latest expo-version: latest
eas-version: latest eas-version: latest
token: ${{ secrets.EXPO_TOKEN }} token: ${{ secrets.EXPO_TOKEN }}
- name: Install dependencies - name: Install dependencies
if: env.IS_EXPO_ENABLED == 'true'
run: yarn install --immutable run: yarn install --immutable
- name: Build Mobile Release - name: Build Mobile Release
if: env.IS_EXPO_ENABLED == 'true'
run: yarn build:mobile:apk | tee log.txt run: yarn build:mobile:apk | tee log.txt
- name: Parse Asset URL - name: Parse Asset URL
id: url id: url
if: env.IS_EXPO_ENABLED == 'true'
run: | run: |
ASSET_URL=$(cat log.txt | jq '.[0].artifacts.buildUrl' -r) ASSET_URL=$(cat log.txt | jq '.[0].artifacts.buildUrl' -r)
echo The android url is $ASSET_URL echo The android url is $ASSET_URL
echo "assetUrl=$ASSET_URL" >> $GITHUB_OUTPUT echo "assetUrl=$ASSET_URL" >> $GITHUB_OUTPUT
- name: Download APK Asset - name: Download APK Asset
if: env.IS_EXPO_ENABLED == 'true'
run: wget -O kyoo.apk ${{ steps.url.outputs.assetUrl }} run: wget -O kyoo.apk ${{ steps.url.outputs.assetUrl }}
- uses: actions/upload-artifact@v4 - uses: actions/upload-artifact@v4
if: env.IS_EXPO_ENABLED == 'true'
with: with:
name: kyoo.apk name: kyoo.apk
path: ./front/kyoo.apk path: ./front/kyoo.apk
- name: Upload release artifacts - name: Upload release artifacts
uses: softprops/action-gh-release@v2 uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/') if: env.IS_EXPO_ENABLED == 'true' && startsWith(github.ref, 'refs/tags/')
with: with:
files: ./front/kyoo.apk files: ./front/kyoo.apk

View File

@ -15,15 +15,20 @@ jobs:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Check for EXPO_TOKEN # This is required because GHA doesn't support secrets in the `if` condition
- name: Check if Expo build is enabled
env:
IS_SECRET_SET: ${{ env.IS_EXPO_ENABLED == 'true' && 'true' || 'false' }}
run: echo "IS_EXPO_ENABLED=${IS_SECRET_SET}" >> "${GITHUB_ENV}"
- name: Log if Expo build is disabled due to fork
if: env.IS_EXPO_ENABLED != 'true'
run: | run: |
if [ -z "${{ secrets.EXPO_TOKEN }}" ]; then echo "Expo build is disabled for forks. To enable it, add an EXPO_TOKEN secret to this repository. See https://docs.expo.dev/eas-update/github-actions/ for more information."
echo "You must provide an EXPO_TOKEN secret linked to this project's Expo account in this repo's secrets. Learn more: https://docs.expo.dev/eas-update/github-actions"
exit 1
fi
- name: Setup Node - name: Setup Node
uses: actions/setup-node@v4 uses: actions/setup-node@v4
if: env.IS_EXPO_ENABLED == 'true'
with: with:
node-version: 22.x node-version: 22.x
cache: yarn cache: yarn
@ -31,13 +36,16 @@ jobs:
- name: Setup Expo - name: Setup Expo
uses: expo/expo-github-action@v8 uses: expo/expo-github-action@v8
if: env.IS_EXPO_ENABLED == 'true'
with: with:
expo-version: latest expo-version: latest
eas-version: latest eas-version: latest
token: ${{ secrets.EXPO_TOKEN }} token: ${{ secrets.EXPO_TOKEN }}
- name: Install dependencies - name: Install dependencies
if: env.IS_EXPO_ENABLED == 'true'
run: yarn install --immutable run: yarn install --immutable
- name: Publish update - name: Publish update
if: env.IS_EXPO_ENABLED == 'true'
run: yarn update run: yarn update