ci: use available aws cli from github hosted virtual environments #6
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: Build and deploy | |
on: | |
push: | |
branches: | |
- 'main' | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Install pnpm | |
uses: pnpm/action-setup@v4 | |
with: | |
version: latest | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: latest | |
cache: 'pnpm' | |
- name: Install dependencies | |
run: pnpm install --frozen-lockfile | |
- name: 'Create env file' | |
run: | | |
touch .env | |
echo HOSTNAME="${{ vars.HOSTNAME }}" >> .env | |
echo NEXT_PUBLIC_APP_NAME="${{ vars.NEXT_PUBLIC_APP_NAME }}" >> .env | |
echo NEXT_ASSET_PREFIX="${{ vars.NEXT_ASSET_PREFIX }}" >> .env | |
echo NEXT_PUBLIC_BASE_PATH="${{ vars.NEXT_PUBLIC_BASE_PATH }}" >> .env | |
- name: Build | |
run: pnpm build | |
- name: Prepare build artifact | |
run: mv .next _next | |
- name: Upload build artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Next build | |
path: _next/ | |
deploy: | |
name: Deploy | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Install pnpm | |
uses: pnpm/action-setup@v4 | |
with: | |
version: latest | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: latest | |
cache: 'pnpm' | |
- name: Install dependencies | |
run: pnpm install --frozen-lockfile | |
working-directory: infrastructure | |
- name: Download build artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: Next build | |
path: .next/ | |
- name: Deploy infrastructure | |
uses: pulumi/actions@v6 | |
with: | |
command: up | |
stack-name: marc-gavanier/cartographie/prod | |
work-dir: infrastructure | |
env: | |
PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }} | |
SCW_ACCESS_KEY: ${{ secrets.SCW_ACCESS_KEY }} | |
SCW_SECRET_KEY: ${{ secrets.SCW_SECRET_KEY }} | |
SCW_DEFAULT_PROJECT_ID: ${{ secrets.SCW_DEFAULT_PROJECT_ID }} | |
TAGS: ${{ vars.TAGS }} | |
- name: Upload static files | |
run: aws --endpoint-url https://s3.fr-par.scw.cloud s3 sync .next/static s3://cartographie-prod-app-static-bucket/_next/static --acl public-read | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.SCW_ACCESS_KEY }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.SCW_SECRET_KEY }} | |
AWS_DEFAULT_REGION: fr-par |