Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate giant to github actions #153

Merged
merged 12 commits into from
Oct 2, 2023
53 changes: 53 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# 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

# Setup Node, checking common Node config files to determine the version of Node to use.
# Configuring caching is also recommended.
# See https://github.com/guardian/actions-setup-node
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version-file: .nvmrc

# Configuring caching is also recommended.
# See https://github.com/actions/setup-java
- name: Setup Java 8
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- name: Setup Java 8
- name: Setup Java 11

uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'

# 1. Seed the build number with last number from TeamCity.
# Update `LAST_TEAMCITY_BUILD` as needed or remove entirely if changing Riff-Raff project name.
# See https://github.com/github/scripts-to-rule-them-all
- name: Run script/teamcity
run: |
LAST_TEAMCITY_BUILD=5000
export GITHUB_RUN_NUMBER=$(( $GITHUB_RUN_NUMBER + $LAST_TEAMCITY_BUILD ))
./scripts/teamcity.sh
5 changes: 4 additions & 1 deletion scripts/teamcity.sh
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be renamed to ci.sh since it no longer runs in TeamCity.

Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't comment on parts of this file that weren't modified in this PR, but lines 4-11 in this script are made redundant by actions/setup-node@v3 in the workflow so they can be removed I think

# 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

# 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
Expand Down