Skip to content

Test policies, build bundle and upload #243

Test policies, build bundle and upload

Test policies, build bundle and upload #243

Workflow file for this run

name: Test policies, build bundle and upload
on:
push:
branches:
- main
- release
workflow_dispatch:
jobs:
build:
name: Test build and upload
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Setup OPA
uses: open-policy-agent/setup-opa@v2
with:
version: latest
- name: Run OPA Tests
run: opa test policies -v
- name: Setup Apollo Studio variant
id: vars
run: |
if [[ "${{ github.ref }}" == "refs/heads/release" ]]; then
echo "variant=current" >> $GITHUB_OUTPUT
echo "environment=prod" >> $GITHUB_OUTPUT
else
echo "variant=stage" >> $GITHUB_OUTPUT
echo "environment=stage" >> $GITHUB_OUTPUT
fi
- name: Retrieve latest GraphQL Schema
env:
APOLLO_KEY: ${{ secrets.APOLLO_KEY }}
run: |
# install rover CLI
curl -sSL https://rover.apollo.dev/nix/latest | sh
export PATH="/home/runner/.rover/bin:$PATH"
# Retrieve and save schema
rover graph fetch hub-dev@${{ steps.vars.outputs.variant }} --skip-update-check --format plain > schema.graphql
- name: Build bundle
if: success()
run: |
json_schema_path=policies/graphql/data.json
schema_raw=$(python3 clean-schema.py schema.graphql) && \
jq --null-input --arg data "$schema_raw" '.schema |= $data' > "$json_schema_path" && \
opa build -b policies
- name: Upload bundle
if: success()
uses: keithweaver/[email protected]
with:
command: cp
source: ./bundle.tar.gz
destination: s3://${{ steps.vars.outputs.environment }}-${{ github.event.repository.name }}/bundle.tar.gz
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws_region: ${{ secrets.AWS_REGION }}