feat: december updates #604
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: 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: netcup-bitbetter | |
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: 22 | |
- name: Replace config file with Prod version | |
run: echo "$ASTRO_CONFIG" > astro.config.mjs | |
- run: cat astro.config.mjs | |
- name: Install Node dependencies | |
run: npm ci | |
- name: Build site | |
run: npm run build | |
- 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: netcup-bitbetter | |
runs-on: ubuntu-latest | |
env: | |
SSH_KNOWN_HOSTS: ${{ secrets.SSH_KNOWN_HOSTS }} | |
SFTP_HOST: ${{ secrets.SFTP_HOST }} | |
SFTP_PATH: ${{ secrets.SFTP_PATH }} | |
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: dist | |
- 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 --only-newer --ignore-time --verbose --delete ./dist ./$SFTP_PATH/${GITHUB_HEAD_REF//\//-} --exclude pdfjs/ ; 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://${GITHUB_HEAD_REF}.dev.tolocar.org/' | |
}) | |