Merge pull request #220 from mykhailodanilenko/feature/tv-modals-setup #95
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build mobile artifacts & deploy static content to Pages | |
on: | |
# Runs on pushes targeting the default branch | |
push: | |
branches: ["main"] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. | |
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. | |
concurrency: | |
group: "owntube-build" | |
cancel-in-progress: false | |
jobs: | |
choose_macos_runner: | |
runs-on: ubuntu-latest | |
environment: owntube | |
outputs: | |
runner-label: ${{ steps.set-macos-runner.outputs.runner-label }} | |
steps: | |
- name: Set macos runner | |
id: set-macos-runner | |
run: | | |
echo "runner-label=${{ vars.PREFERRED_MACOS_RUNNER || 'macos-latest' }}" >> $GITHUB_OUTPUT | |
build_info: | |
runs-on: ubuntu-latest | |
outputs: | |
BUILD_INFO: ${{ steps.write.outputs.BUILD_INFO }} | |
steps: | |
- id: create | |
name: "@${{ github.actor }} initiated GitHub Pages deployment, prepare build info" | |
run: | | |
# Builder username on GitHub | |
echo "GITHUB_ACTOR=${{ github.actor }}" && echo "GITHUB_ACTOR=${{ github.actor }}" >> "$GITHUB_OUTPUT" | |
# Create short Git SHA equivalent to `$(git rev-parse --short HEAD)` e.g. "d1f5cfd" | |
GITHUB_SHA_SHORT="${GITHUB_SHA::7}" | |
echo "GITHUB_SHA_SHORT=$GITHUB_SHA_SHORT" && echo "GITHUB_SHA_SHORT=$GITHUB_SHA_SHORT" >> "$GITHUB_OUTPUT" | |
# Create commit URL, e.g. "https://github.com/OwnTube-tv/web-client/commit/d1f5cfd" | |
COMMIT_URL="https://github.com/${{ github.repository }}/commit/$GITHUB_SHA_SHORT" | |
echo "COMMIT_URL=$COMMIT_URL" && echo "COMMIT_URL=$COMMIT_URL" >> "$GITHUB_OUTPUT" | |
# Create ISO format build timestamp in UTC, e.g. "2024-02-19T13:12:52Z" | |
BUILD_TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ") | |
echo "BUILD_TIMESTAMP=$BUILD_TIMESTAMP" && echo "BUILD_TIMESTAMP=$BUILD_TIMESTAMP" >> "$GITHUB_OUTPUT" | |
# Extract part after '/' in github.repository | |
REPO_NAME=$(echo "${{ github.repository }}" | awk -F/ '{print $2}') | |
echo "REPO_NAME=$REPO_NAME" && echo "REPO_NAME=$REPO_NAME" >> "$GITHUB_OUTPUT" | |
# Create web url | |
WEB_URL="https://${{ github.repository_owner }}.github.io/$REPO_NAME" | |
echo "WEB_URL=$WEB_URL" && echo "WEB_URL=$WEB_URL" >> "$GITHUB_OUTPUT" | |
- id: write | |
run: | | |
echo "BUILD_INFO<<EOF" >> $GITHUB_OUTPUT | |
echo "{ | |
\"GITHUB_ACTOR\": \"${{ steps.create.outputs.GITHUB_ACTOR }}\", | |
\"GITHUB_SHA_SHORT\": \"${{ steps.create.outputs.GITHUB_SHA_SHORT }}\", | |
\"COMMIT_URL\": \"${{ steps.create.outputs.COMMIT_URL }}\", | |
\"BUILD_TIMESTAMP\": \"${{ steps.create.outputs.BUILD_TIMESTAMP }}\", | |
\"WEB_URL\": \"${{ steps.create.outputs.WEB_URL }}\" | |
} | |
" >> $GITHUB_OUTPUT | |
echo "EOF" >> $GITHUB_OUTPUT | |
customizations_setup: | |
runs-on: ubuntu-latest | |
environment: owntube | |
outputs: | |
CUSTOMIZATIONS_ENV_CONTENT: ${{ steps.read_customization_file.outputs.CUSTOMIZATIONS_ENV_CONTENT }} | |
steps: | |
- name: Check for Customization Variables | |
id: check_customizations | |
run: | | |
if [[ -n "${{ vars.CLIENT_CUSTOMIZATIONS_REPO }}" && -n "${{ vars.CLIENT_CUSTOMIZATIONS_FILE }}" ]]; then | |
echo "should_run_customizations=true" >> $GITHUB_OUTPUT | |
else | |
echo "should_run_customizations=false" >> $GITHUB_OUTPUT | |
fi | |
- name: Clone customizations repository | |
if: steps.check_customizations.outputs.should_run_customizations == 'true' | |
run: | | |
git clone "${{ vars.CLIENT_CUSTOMIZATIONS_REPO }}" customizations-repo | |
- name: Find and read the customization file | |
id: read_customization_file | |
if: steps.check_customizations.outputs.should_run_customizations == 'true' | |
run: | | |
CUSTOMIZATION_FILE_PATH="customizations-repo/${{ vars.CLIENT_CUSTOMIZATIONS_FILE }}" | |
if [[ -f "$CUSTOMIZATION_FILE_PATH" ]]; then | |
echo "$(cat "$CUSTOMIZATION_FILE_PATH")" | |
echo 'CUSTOMIZATIONS_ENV_CONTENT<<EOF' >> $GITHUB_OUTPUT | |
printf "%s\n" $(cat "$CUSTOMIZATION_FILE_PATH") >> $GITHUB_OUTPUT | |
echo 'EOF' >> $GITHUB_OUTPUT | |
else | |
exit 1 | |
fi | |
code_quality: | |
needs: [customizations_setup, build_info] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Node 20 | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
- name: Install Dependencies | |
run: cd OwnTube.tv/ && npm install | |
- name: Check ESLint Code Style | |
run: cd OwnTube.tv/ && npx eslint . | |
- name: Check Prettier Formatting | |
run: cd OwnTube.tv/ && npx prettier --check ../ | |
- name: Run Tests | |
run: cd OwnTube.tv/ && npm run test | |
build_android_apk: | |
needs: [code_quality, build_info, customizations_setup] | |
uses: ./.github/workflows/build_android_apk.yml | |
with: | |
customizations_env_content: ${{ needs.customizations_setup.outputs.CUSTOMIZATIONS_ENV_CONTENT }} | |
build_info: ${{ needs.build_info.outputs.BUILD_INFO }} | |
build_android_tv_apk: | |
needs: [code_quality, build_info, customizations_setup] | |
uses: ./.github/workflows/build_android_tv_apk.yml | |
with: | |
customizations_env_content: ${{ needs.customizations_setup.outputs.CUSTOMIZATIONS_ENV_CONTENT }} | |
build_info: ${{ needs.build_info.outputs.BUILD_INFO }} | |
build_ios_app: | |
needs: [build_info, customizations_setup, code_quality, choose_macos_runner] | |
uses: ./.github/workflows/build_ios_app.yml | |
with: | |
runner-label: ${{ needs.choose_macos_runner.outputs.runner-label }} | |
customizations_env_content: ${{ needs.customizations_setup.outputs.CUSTOMIZATIONS_ENV_CONTENT }} | |
build_info: ${{ needs.build_info.outputs.BUILD_INFO }} | |
build_tvos_app: | |
needs: [build_info, customizations_setup, code_quality, choose_macos_runner] | |
uses: ./.github/workflows/build_tvos_app.yml | |
with: | |
runner-label: ${{ needs.choose_macos_runner.outputs.runner-label }} | |
customizations_env_content: ${{ needs.customizations_setup.outputs.CUSTOMIZATIONS_ENV_CONTENT }} | |
build_info: ${{ needs.build_info.outputs.BUILD_INFO }} | |
deploy_web: | |
needs: [code_quality, build_info, customizations_setup] | |
uses: ./.github/workflows/deploy_web.yml | |
with: | |
customizations_env_content: ${{ needs.customizations_setup.outputs.CUSTOMIZATIONS_ENV_CONTENT }} | |
build_info: ${{ needs.build_info.outputs.BUILD_INFO }} |