diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..6e61c257 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,48 @@ +# Find full documentation here https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions +name: CI + +on: + # Manual invocation. + workflow_dispatch: + + push: + +jobs: + CI: + runs-on: ubuntu-latest + + # See https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token + permissions: + # required by aws-actions/configure-aws-credentials + id-token: write + contents: read + steps: + - uses: actions/checkout@v4 + + # Setup AWS credentials to enable uploading to S3 for Riff-Raff. + # See https://github.com/aws-actions/configure-aws-credentials + - uses: aws-actions/configure-aws-credentials@v4 + name: setup-riffraff-credentials + with: + role-to-assume: ${{ secrets.GU_RIFF_RAFF_ROLE_ARN }} + aws-region: eu-west-1 + + # TODO: configure caching + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version-file: .nvmrc + + # TODO: configure caching + # See https://github.com/actions/setup-java + - name: Setup Java + uses: actions/setup-java@v3 + with: + java-version: '11' + distribution: 'adopt' + + - name: Run script/teamcity + run: | + LAST_TEAMCITY_BUILD=5000 + export GITHUB_RUN_NUMBER=$(( $GITHUB_RUN_NUMBER + $LAST_TEAMCITY_BUILD )) + ./scripts/ci.sh diff --git a/riff-raff.yaml b/riff-raff.yaml index 7feba1df..5b94e584 100644 --- a/riff-raff.yaml +++ b/riff-raff.yaml @@ -1,4 +1,4 @@ -# We implement deploying to multiple stages by doing multiple builds in `teamcity.sh` +# We implement deploying to multiple stages by doing multiple builds in `ci.sh` # updating all references to `pfi-playground` in this file between each. stacks: [pfi-playground] regions: [eu-west-1] diff --git a/scripts/teamcity.sh b/scripts/ci.sh similarity index 70% rename from scripts/teamcity.sh rename to scripts/ci.sh index 29e6c519..05d76602 100755 --- a/scripts/teamcity.sh +++ b/scripts/ci.sh @@ -1,15 +1,6 @@ #!/usr/bin/env bash set -e -# Make Create React App treat warnings as errors -export CI=true - -export NVM_DIR="$HOME/.nvm" -[[ -s "$NVM_DIR/nvm.sh" ]] && . "$NVM_DIR/nvm.sh" # This loads nvm - -nvm install -nvm use - pushd frontend npm install @@ -21,7 +12,10 @@ popd cp -r frontend/build/* backend/public # Replace the symbolic link we use in dev with the actual file. # On Teamcity the JDeb build doesn't seem to follow the symbolic link while packaging, weirdly -cp frontend/node_modules/pdfjs-dist/build/pdf.worker.min.js backend/public/third-party/pdf.worker.min.js +# NOTE: On Github actions this seems to work, and in fact it will complain if you try and run the below line +# because it thinks that the two files are the same. So could be removed at some point but let's leave it for +# a bit in case e.g. github actions custom runners have similar issues +#cp frontend/node_modules/pdfjs-dist/build/pdf.worker.min.js backend/public/third-party/pdf.worker.min.js #Use java 11 export JAVA_HOME=/usr/lib/jvm/java-11-amazon-corretto