Merge pull request #108 from prose-im/master #95
This file contains 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
on: | |
push: | |
branches: | |
- production | |
name: Build and Deploy | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
with: | |
lfs: true | |
- name: Install NodeJS | |
uses: actions/setup-node@v1 | |
with: | |
node-version: 20.x | |
- name: Verify versions | |
run: node --version && npm --version && node -p process.versions.v8 | |
- name: Cache build context | |
id: cache-node | |
uses: actions/cache@v2 | |
with: | |
path: | | |
~/.npm | |
node_modules | |
key: ${{ runner.os }}-node | |
- name: Get current revision | |
id: current_revision | |
uses: pr-mpt/actions-commit-hash@v1 | |
- name: Install dependencies | |
run: npm install --no-audit | |
- name: Ensure all tests pass | |
run: npm test | |
- name: Build website | |
run: npm run build | |
- name: Archive build files | |
run: tar -zcvf ./build-${{ steps.current_revision.outputs.short }}.tar.gz build/ | |
- name: Deploy website | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_SECRET_ACCESS_KEY }} | |
AWS_EC2_METADATA_DISABLED: true | |
run: | | |
aws s3 sync --delete --endpoint-url ${{ secrets.S3_ENDPOINT }} build/ s3://${{ secrets.S3_BUCKET }}/${{ secrets.S3_SITE_DOMAIN }}/ | |
- name: Upload build artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ steps.current_revision.outputs.short }} Build | |
path: ./build-${{ steps.current_revision.outputs.short }}.tar.gz | |
retention-days: 7 |