Skip to content

Commit

Permalink
Pull in upload action
Browse files Browse the repository at this point in the history
  • Loading branch information
nbolton committed Sep 26, 2024
1 parent d0ac277 commit 08e90ea
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 11 deletions.
69 changes: 69 additions & 0 deletions .github/actions/dist-upload/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: "Distribute upload"
description: "Uploads the package from the dist dir to GitHub artifacts or Google Drive"
inputs:
use-github:
description: "Whether to upload to GitHub artifacts"
required: true

use-gdrive:
description: "Whether to upload to Google Drive"
required: true

github-target-filename:
description: "Filename to upload (GitHub artifacts)"
required: true

gdrive-target-base-dir:
description: "Base directory to upload (Google Drive)"
required: true

gdrive-secret-key:
description: "Google Drive secret key"
required: true

gdrive-parent-folder-id:
description: "Google Drive parent folder ID"
required: true

package-version:
description: "Package version appended to the Google Drive dir"
required: true

runs:
using: "composite"

steps:
- if: ${{ inputs.use_gdrive == inputs.use-github }}
run: |
echo "Either 'use-github' or 'use_gdrive' must be true (and not both)"
exit 1
shell: bash

- if: ${{ inputs.use_gdrive == 'true' && !inputs.package-version }}
run: |
echo "Input 'package-version' is required when uploading to Google Drive"
exit 1
shell: bash

- if: ${{ inputs.use_gdrive == 'true' }}
run: |
SHORT_VERSION=$(echo "${{ inputs.package-version }}" | cut -d'-' -f1 | cut -d'+' -f1)
echo "SHORT_VERSION=$SHORT_VERSION" >> $GITHUB_ENV
shell: bash

- name: Upload to GitHub
if: ${{ inputs.use-github == 'true' }}
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.github-target-filename }}
path: ./dist
retention-days: 3

- name: Upload to Google Drive
if: ${{ inputs.use_gdrive == 'true' }}
uses: symless/gdrive-upload@target-glob
with:
credentials: ${{ inputs.gdrive-secret-key }}
target: "./dist/*"
parent_folder_id: ${{ inputs.gdrive-parent-folder-id }}
child_folder: Packages/${{ inputs.gdrive-target-base-dir }}/${{ env.SHORT_VERSION }}/${{ inputs.package-version }}
37 changes: 26 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@ on:

env:
GIT_SHA: ${{ github.sha }}
PACKAGE_BUILD: ${{ !github.event.pull_request.draft }}
PACKAGE_UPLOAD: ${{ !github.event.pull_request.draft }}
SYNERGY_PRODUCT_NAME: ${{ vars.SYNERGY_PRODUCT_NAME }}
SYNERGY_PACKAGE_PREFIX: ${{ vars.SYNERGY_PACKAGE_PREFIX }}
SYNERGY_ENABLE_ACTIVATION: ${{ vars.SYNERGY_ENABLE_ACTIVATION }}
PACKAGE_BUILD: ${{ !github.event.pull_request.draft }}
PACKAGE_UPLOAD: ${{ !github.event.pull_request.draft }}
UPLOAD_TO_GITHUB: ${{ github.event_name == 'pull_request' && !github.event.pull_request.draft }}
UPLOAD_TO_GDRIVE: ${{ github.event_name != 'pull_request' }}

jobs:
# Quality gate to allow PR merge, used in the branch protection rules.
Expand Down Expand Up @@ -116,11 +119,15 @@ jobs:

- name: Upload
if: ${{ env.PACKAGE_UPLOAD == 'true' }}
uses: ./deskflow/.github/actions/dist-upload
uses: ./.github/actions/dist-upload
with:
use-github: true
use-github: ${{ env.UPLOAD_TO_GITHUB }}
use-gdrive: ${{ env.UPLOAD_TO_GDRIVE }}
github-target-filename: "${{ env.SYNERGY_PACKAGE_PREFIX }}-${{ matrix.target.name }}"
package-version: ${{ env.DESKFLOW_VERSION }}
gdrive-target-base-dir: ${{ vars.GDRIVE_TARGET_BASE_DIR }}
gdrive-secret-key: ${{ secrets.GOOGLE_DRIVE_KEY }}
gdrive-parent-folder-id: ${{ secrets.GOOGLE_DRIVE_TECH_DRIVE }}
package-version: ${{ env.SYNERGY_VERSION }}

macos:
name: ${{ matrix.target.name }}
Expand Down Expand Up @@ -195,11 +202,15 @@ jobs:

- name: Upload
if: ${{ env.PACKAGE_UPLOAD == 'true' }}
uses: ./deskflow/.github/actions/dist-upload
uses: ./.github/actions/dist-upload
with:
use-github: true
use-github: ${{ env.UPLOAD_TO_GITHUB }}
use-gdrive: ${{ env.UPLOAD_TO_GDRIVE }}
github-target-filename: "${{ env.SYNERGY_PACKAGE_PREFIX }}-${{ matrix.target.name }}"
package-version: ${{ env.DESKFLOW_VERSION }}
gdrive-target-base-dir: ${{ vars.GDRIVE_TARGET_BASE_DIR }}
gdrive-secret-key: ${{ secrets.GOOGLE_DRIVE_KEY }}
gdrive-parent-folder-id: ${{ secrets.GOOGLE_DRIVE_TECH_DRIVE }}
package-version: ${{ env.SYNERGY_VERSION }}

linux-matrix:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -272,8 +283,12 @@ jobs:

- name: Upload
if: ${{ env.PACKAGE_UPLOAD == 'true' }}
uses: ./deskflow/.github/actions/dist-upload
uses: ./.github/actions/dist-upload
with:
use-github: true
use-github: ${{ env.UPLOAD_TO_GITHUB }}
use-gdrive: ${{ env.UPLOAD_TO_GDRIVE }}
github-target-filename: "${{ env.SYNERGY_PACKAGE_PREFIX }}-${{ matrix.distro.name }}"
package-version: ${{ env.DESKFLOW_VERSION }}
gdrive-target-base-dir: ${{ vars.GDRIVE_TARGET_BASE_DIR }}
gdrive-secret-key: ${{ secrets.GOOGLE_DRIVE_KEY }}
gdrive-parent-folder-id: ${{ secrets.GOOGLE_DRIVE_TECH_DRIVE }}
package-version: ${{ env.SYNERGY_VERSION }}

0 comments on commit 08e90ea

Please sign in to comment.