define sample apps in sample app json to be used by the console #26
Workflow file for this run
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: Deploy | |
| on: | |
| push: | |
| branches: | |
| - master | |
| pull_request: | |
| branches: | |
| - master | |
| defaults: | |
| run: | |
| # Specify to ensure "pipefail and errexit" are set. | |
| # Ref: https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#defaultsrunshell | |
| shell: bash | |
| permissions: | |
| contents: read | |
| id-token: write # Required for OIDC authentication | |
| deployments: write | |
| jobs: | |
| setup: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| app-list-json: ${{ steps.read-json.outputs.APP_LIST }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Read JSON | |
| id: read-json | |
| run: | | |
| delimiter="$(openssl rand -hex 8)" | |
| { | |
| echo "APP_LIST<<${delimiter}" | |
| sed -e '$a\' console-sample-apps.json # Ensures that an empty line is always present. | |
| echo "${delimiter}" | |
| } >> "$GITHUB_OUTPUT" | |
| - name: Upload artifact JSON | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: console-json | |
| path: console-sample-apps.json | |
| create-zip: | |
| runs-on: ubuntu-latest | |
| needs: | |
| - setup | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| app: ${{ fromJSON(needs.setup.outputs.app-list-json) }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Create artifact | |
| env: | |
| DEBUG: ${{ runner.debug }} # Automatically set by GitHub Actions when running in debug mode. | |
| run: | | |
| ./scripts/build-sample-app.sh "${{ matrix.app.name }}" | |
| # Ensure that both application.zip and documents.jsonl are created. | |
| if [ ! -f "${{ matrix.app.name }}/dist/application.zip" ] || | |
| [ ! -f "${{ matrix.app.name }}/dist/documents.jsonl" ]; then | |
| echo "::error:: Build failure: application.zip or documents.jsonl not found in ${GITHUB_WORKSPACE}/${{ matrix.app.name }}/dist/" | |
| exit 1 | |
| fi | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.app.shortname }} | |
| path: ${{ matrix.app.name }}/dist/ | |
| deploy-json: | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: Vespa Cloud | |
| url: https://cloud.vespa.ai | |
| needs: | |
| - create-zip | |
| steps: | |
| - name: Download All Packages | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: apps | |
| - name: List Downloaded | |
| if: ${{ runner.debug }} | |
| run: | | |
| ls -lr apps | |
| - name: Setup AWS Credentials | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| aws-region: us-east-1 | |
| role-to-assume: arn:aws:iam::332934501266:role/github-deploy-sample-apps | |
| - name: Push Zip and JSON to S3 | |
| id: deploy | |
| env: | |
| AWS_REGION: us-east-1 | |
| # Add `--dryrun` if not on "push" event on default branch. | |
| AWS_S3_OPTIONS: --color=on --no-progress ${{ (github.event_name == 'push' && github.ref_name == 'master' ) && '' || ' --dryrun' }} | |
| run: | | |
| aws s3 sync ${{ env.AWS_S3_OPTIONS }} ./apps/ s3://vespa-cloud-data/console/one-click-sample-apps/ | |
| aws s3 cp ${{ env.AWS_S3_OPTIONS }} ./console-json/console-sample-apps.json s3://vespa-cloud-data/console/one-click-sample-apps/ |