Skip to content

feat: december updates #589

feat: december updates

feat: december updates #589

Workflow file for this run

name: Preview Deployment
on:
pull_request:
workflow_dispatch:
# Allow this job to clone the repo and create a page deployment
permissions:
contents: read
id-token: write
pull-requests: write
jobs:
build:
runs-on: ubuntu-latest
environment: ionos
env:
ASTRO_CONFIG: ${{ secrets.ASTRO_CONFIG }}
PUBLIC_MAPBOX_TOKEN: ${{ secrets.PUBLIC_MAPBOX_TOKEN }}
AIRTABLE_TOKEN: ${{ secrets.AIRTABLE_TOKEN }}
INTERVENTIONS_AIRTABLE_BASE_ID: ${{ secrets.INTERVENTIONS_AIRTABLE_BASE_ID }}
NEWS_AIRTABLE_BASE_ID: ${{ secrets.NEWS_AIRTABLE_BASE_ID }}
steps:
- name: Set env to use shell substitution logic
run: echo "ASTRO_BASE_PATH=${GITHUB_HEAD_REF//\//-}" >> $GITHUB_ENV
- name: Checkout repository using git
uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 20
- name: Replace config file with Prod version
run: echo "$ASTRO_CONFIG" > astro.config.mjs
- name: Install Node dependencies
run: npm ci
- name: Build site
run: npm run build
- name: Move images News
run: mv public/images/news/dynamic/* dist/images/news/dynamic/
- name: Move images Interventions
run: mv public/images/interventions/dynamic/* dist/images/interventions/dynamic/
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: deployment
retention-days: 5
path: ./dist
deploy:
needs: build
environment: ionos
runs-on: ubuntu-latest
env:
SSH_KNOWN_HOSTS: ${{ secrets.SSH_KNOWN_HOSTS }}
SFTP_HOST: ${{ secrets.SFTP_HOST }}
SFTP_USER: ${{ secrets.SFTP_USER }}
SFTP_PASSWORD: ${{ secrets.SFTP_PASSWORD }}
steps:
- name: Set env to use shell substitution logic
run: echo "ASTRO_BASE_PATH=${GITHUB_HEAD_REF//\//-}" >> $GITHUB_ENV
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: deployment
path: ${{ env.ASTRO_BASE_PATH }}
- name: Install LFTP
run: sudo apt-get install -y lftp
- name: Add SSH Known Hosts
run: |
mkdir -p ~/.ssh/
echo "$SSH_KNOWN_HOSTS" >> ~/.ssh/known_hosts
- name: List dir
run: |
pwd
ls -la
- name: Deploy via LFTP to SFTP target
run: lftp -e "set ftp:list-options -a; set net:timeout 5; set net:max-retries 3; set net:reconnect-interval-base 5; open sftp://$SFTP_HOST; user $SFTP_USER $SFTP_PASSWORD; mirror --reverse --verbose --delete ./${GITHUB_HEAD_REF//\//-}; bye"
- name: Comment on PR
uses: actions/github-script@v3
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '✅ Successfully deployed to: https://dev.tolocar.org/${{ env.ASTRO_BASE_PATH }}'
})