|
| 1 | +name: Build NRL Project on Environment |
| 2 | +run-name: Build NRL Project on ${{ inputs.environment || 'dev' }} |
| 3 | +permissions: |
| 4 | + id-token: write |
| 5 | + contents: read |
| 6 | + actions: write |
| 7 | + |
| 8 | +on: |
| 9 | + schedule: |
| 10 | + - cron: "0 1 * * *" |
| 11 | + workflow_dispatch: |
| 12 | + inputs: |
| 13 | + environment: |
| 14 | + type: environment |
| 15 | + description: "The environment to deploy changes to" |
| 16 | + default: "dev" |
| 17 | + required: true |
| 18 | + |
| 19 | +jobs: |
| 20 | + build: |
| 21 | + name: Build - develop |
| 22 | + runs-on: [self-hosted, ci] |
| 23 | + |
| 24 | + steps: |
| 25 | + - name: Git clone - develop |
| 26 | + uses: actions/checkout@v4 |
| 27 | + with: |
| 28 | + ref: develop |
| 29 | + |
| 30 | + - name: Setup asdf cache |
| 31 | + uses: actions/cache@v4 |
| 32 | + with: |
| 33 | + path: ~/.asdf |
| 34 | + key: ${{ runner.os }}-asdf-${{ hashFiles('**/.tool-versions') }} |
| 35 | + restore-keys: | |
| 36 | + ${{ runner.os }}-asdf- |
| 37 | +
|
| 38 | + - name: Install asdf |
| 39 | + uses: asdf-vm/actions/[email protected] |
| 40 | + with: |
| 41 | + asdf_branch: v0.13.1 |
| 42 | + |
| 43 | + - name: Install zip |
| 44 | + run: sudo apt-get install zip |
| 45 | + |
| 46 | + - name: Setup Python environment |
| 47 | + run: | |
| 48 | + poetry install --no-root |
| 49 | + source $(poetry env info --path)/bin/activate |
| 50 | +
|
| 51 | + - name: Run Linting |
| 52 | + run: make lint |
| 53 | + |
| 54 | + - name: Run Unit Tests |
| 55 | + run: make test |
| 56 | + |
| 57 | + - name: Build Project |
| 58 | + run: make build |
| 59 | + |
| 60 | + - name: Configure Management Credentials |
| 61 | + uses: aws-actions/configure-aws-credentials@v4 |
| 62 | + with: |
| 63 | + aws-region: eu-west-2 |
| 64 | + role-to-assume: ${{ secrets.MGMT_ROLE_ARN }} |
| 65 | + role-session-name: github-actions-ci-${{ inputs.environment || 'dev' }}-${{ github.run_id }} |
| 66 | + |
| 67 | + - name: Add S3 Permissions to Lambda |
| 68 | + run: | |
| 69 | + account=$(echo '${{ inputs.environment || 'dev' }}' | cut -d '-' -f1) |
| 70 | + inactive_stack=$(poetry run python ./scripts/get_env_config.py inactive-stack ${{ inputs.environment || 'dev' }}) |
| 71 | + make get-s3-perms ENV=${account} TF_WORKSPACE_NAME=${inactive_stack} |
| 72 | +
|
| 73 | + - name: Save Build Artifacts |
| 74 | + uses: actions/upload-artifact@v4 |
| 75 | + with: |
| 76 | + name: build-artifacts |
| 77 | + path: | |
| 78 | + dist/*.zip |
| 79 | + !dist/nrlf_permissions.zip |
| 80 | +
|
| 81 | + - name: Save NRLF Permissions cache |
| 82 | + uses: actions/cache/save@v4 |
| 83 | + with: |
| 84 | + key: ${{ github.run_id }}-nrlf-permissions |
| 85 | + path: dist/nrlf_permissions.zip |
0 commit comments