This file contains hidden or 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: 'Download Google Drive File' | |
| env: | |
| ARTIFACT_NAME: GoogleDriveFile | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| tags: | |
| description: "Google AppScript Trigger for Deployment" | |
| required: false | |
| type: string | |
| # TODO: Remove - for testing purposes only | |
| push: | |
| branches: [AdditionalAutomation] | |
| jobs: | |
| download: | |
| name: Install Python and Download File from Google Drive | |
| runs-on: ubuntu-latest | |
| env: | |
| GOOGLE_FILE_ID: ${{ secrets.GOOGLE_FILE_ID }} | |
| GOOGLE_SERVICE_ACCOUNT: ${{ secrets.GOOGLE_SERVICE_ACCOUNT }} | |
| defaults: | |
| run: | |
| shell: bash | |
| working-directory: ./.github/scripts | |
| outputs: | |
| file: ${{steps.verification.outputs.nonEmpty}} | |
| steps: | |
| - name: Checkout Github repository | |
| uses: actions/checkout@v4 | |
| - name: setup Python 3.10+ on runner | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.13' | |
| cache: 'pip' # caching pip dependencies | |
| - name: Install Python Dependencies | |
| run: pip install -r requirements.txt | |
| - name: Create credentials file for Google | |
| run: | | |
| echo $GOOGLE_SERVICE_ACCOUNT > services_encoded.json | |
| wc -c services_encoded.json | |
| cat services_encoded.json | base64 -di > services.json | |
| wc -c services.json | |
| - name: Download file from Google Drive | |
| run: python3 ./GoogleDriveFileDownloader.py | |
| - id: verification | |
| name: Verify non-empty file was downloaded | |
| run: echo "nonEmpty=$(test -s index.html)" >> "$GITHUB_OUTPUT" | |
| - name: Validate job outputs store properly | |
| run: echo "Value of nonEmpty is:$(((${{steps.verification.outputs.file}}) && true && echo "non-empty") || echo "empty")" | |
| - name: Cache the file - to be used in deployment workflow | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: $ARTIFACT_NAME | |
| path: ./index.html | |
| retention-days: 9 | |
| overwrite: true | |
| if: ${{ steps.verification.outputs.file }} && true | |
| - name: cleanup - ensure credentials and temporary files removed from runner | |
| run: | | |
| rm -f services.json | |
| rm -f services_decoded.json | |
| rm -f index.html | |
| if: ${{ always() }} | |
| trigger-deployment: | |
| uses: teracross/webhosting/.github/workflows/deploy.yaml@AdditionalAutomation | |
| needs: download | |
| with: | |
| artifact-name: $ARTIFACT_NAME | |
| permissions: | |
| id-token: write | |
| contents: read | |
| if: ${{ needs.download.outputs.file }} && true | |