deploy-website #23
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
name: Deploy Website | |
on: | |
repository_dispatch: | |
types: | |
- deploy-website | |
- deploy-website-command | |
# push: | |
# branches: | |
# - main | |
# paths: | |
# - "website/**" | |
# - "!website/tests/**" | |
# - "!website/Makefile" | |
# - "!website/README.md" | |
workflow_dispatch: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
# Permissions for terramform-init action | |
permissions: | |
id-token: write | |
contents: read | |
env: | |
WORKSPACE: "production" | |
jobs: | |
deploy-website: | |
name: Deploy | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Load ENV | |
run: | | |
if [ "${{ github.event.client_payload.slash_command.args.named.pr_sha }}" == "" ]; then | |
echo "COMMIT_SHA=${{ github.sha }}" >> $GITHUB_ENV | |
else | |
echo "COMMIT_SHA=${{ github.event.client_payload.slash_command.args.named.pr_sha }}" >> $GITHUB_ENV | |
fi | |
- name: Check out code | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ env.COMMIT_SHA }} | |
- name: Setup Python 3.12 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.12" | |
cache: "pip" | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: "website/.nvmrc" | |
cache-dependency-path: website/yarn.lock | |
cache: "yarn" | |
- name: Terraform Init | |
id: terraform | |
uses: ./.github/workflows/actions/terraform-init | |
timeout-minutes: 5 | |
with: | |
WORKSPACE: ${{ env.WORKSPACE }} | |
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }} | |
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }} | |
AWS_ROLE_NAME: ${{ secrets.AWS_ROLE_NAME }} | |
AWS_TERRAFORM_STATE_BUCKET: ${{ secrets.AWS_TERRAFORM_STATE_BUCKET }} | |
- name: Build | |
timeout-minutes: 5 | |
run: | | |
make setup-website VIRTUAL_ENV=false | |
make build | |
- name: Deploy | |
timeout-minutes: 5 | |
run: | | |
make deploy | |
- name: Update comment | |
if: ${{ success() && github.event.client_payload.slash_command.args.named.comment_id }} | |
uses: peter-evans/create-or-update-comment@v4 | |
with: | |
token: ${{ secrets.ACTION_WORKFLOWS }} | |
comment-id: ${{ github.event.client_payload.slash_command.args.named.comment_id }} | |
reactions: hooray | |
- name: Failure | |
if: ${{ failure() && github.event.client_payload.slash_command.args.named.comment_id }} | |
uses: peter-evans/create-or-update-comment@v4 | |
with: | |
token: ${{ secrets.ACTION_WORKFLOWS }} | |
comment-id: ${{ github.event.client_payload.slash_command.args.named.comment_id }} | |
body: | | |
:warning: Deployment failed. See #[${{ github.run_number }}](https://github.com/italia-opensource/italiaopensource.com/actions/runs/${{ github.run_id }}) for more details. |