Skip to content

Commit

Permalink
add ci.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandzors committed Jun 6, 2024
1 parent 716f733 commit 256b7b5
Show file tree
Hide file tree
Showing 2 changed files with 153 additions and 2 deletions.
151 changes: 151 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
name: Deploy Site

on:
push:
branches:
- dev
- main

jobs:
prod:
if: github.ref =='refs/heads/main' && !contains(github.event.head_commit.message, '!noci')
runs-on: ubuntu-latest
steps:
- name: checkout repo
uses: actions/checkout@v4

- name: setup node
uses: actions/setup-node@v4
with:
node-version: '20.12.1'
cache: 'npm'

- name: Public IP
id: ip
uses: candidob/get-runner-ip@v1.0.0

- name: Setup Linode Cloud Firewall
uses: linode/action-linode-cli@v1
with:
token: "${{ secrets.LINODE_CLI_TOKEN }}"

- name: build dev
id: build
run: |
sed -i -e 's#{GA_ID}#'${{ secrets.GOOGLE_ANALYTICS_ID }}'#g' ./src/layouts/DefaultLayout.astro
npm install
npm run build
- name: test production site
uses: chabad360/htmlproofer@master
id: testing
with:
directory: "./dist/"
arguments: --disable-external --checks --allow-hash-href --ignore_urls "/^http:\/\/127.0.0.1/,/^http:\/\/0.0.0.0/,/^http:\/\/localhost/"

- name: Setup SSH
id: ssh-setup
run: |
mkdir ~/.ssh
touch ~/.ssh/known_hosts
echo ${{ secrets.LINODEFINGERPRINT }} >> ~/.ssh/known_hosts
- name: Open Linode Cloud Firewall for GH
if: (steps.ssh-setup.outcome == 'success')
id: linode-fw-open
env:
PUB_IP: "${{ steps.ip.outputs.ipv4 }}/32"
HOME_IP: "${{ secrets.HOMEIP }}"
LINODE_FW_ID: "${{ secrets.LINODE_FW_ID }}"
run: |
wget https://raw.githubusercontent.com/alexandzors/utils/main/linode-scripts/linode.sh
bash ./linode.sh -a --verbose
- name: deploy blog
uses: burnett01/rsync-deployments@5.2.1
id: deploy
with:
switches: -avr
path: ./dist/
remote_path: /opt/sites/agnet/
remote_host: ${{ secrets.LINODEHOST }}
remote_port: 22
remote_user: ${{ secrets.LINODEUSER }}
remote_key: ${{ secrets.LINODESSHKEY }}

- name: Close Linode Cloud Firewall for GH
if: (steps.deploy.outcome == 'success') || (steps.deploy.outcome == 'failed' || steps.deploy.outcome == 'skipped')
id: linode-fw-close
run: |
bash ./linode.sh -d --verbose
dev:
if: github.ref =='refs/heads/dev' && !contains(github.event.head_commit.message, '!noci')
runs-on: ubuntu-latest
steps:
- name: checkout repo
uses: actions/checkout@v4

- name: setup node
uses: actions/setup-node@v4
with:
node-version: '20.12.1'
cache: 'npm'

- name: Public IP
id: ip
uses: candidob/get-runner-ip@v1.0.0

- name: Setup Linode Cloud Firewall
uses: linode/action-linode-cli@v1
with:
token: "${{ secrets.LINODE_CLI_TOKEN }}"

- name: build dev
id: build
run: |
npm install
npm run build
- name: test production site
uses: chabad360/htmlproofer@master
id: testing
with:
directory: "./dist/"
arguments: --disable-external --checks --allow-hash-href --ignore_urls "/^http:\/\/127.0.0.1/,/^http:\/\/0.0.0.0/,/^http:\/\/localhost/"

- name: Setup SSH
id: ssh-setup
run: |
mkdir ~/.ssh
touch ~/.ssh/known_hosts
echo ${{ secrets.LINODEFINGERPRINT }} >> ~/.ssh/known_hosts
- name: Open Linode Cloud Firewall for GH
if: (steps.ssh-setup.outcome == 'success')
id: linode-fw-open
env:
PUB_IP: "${{ steps.ip.outputs.ipv4 }}/32"
HOME_IP: "${{ secrets.HOMEIP }}"
LINODE_FW_ID: "${{ secrets.LINODE_FW_ID }}"
run: |
wget https://raw.githubusercontent.com/alexandzors/utils/main/linode-scripts/linode.sh
bash ./linode.sh -a --verbose
- name: deploy blog
uses: burnett01/rsync-deployments@5.2.1
id: deploy
with:
switches: -avr
path: ./dist/
remote_path: /opt/sites/agnet-dev/
remote_host: ${{ secrets.LINODEHOST }}
remote_port: 22
remote_user: ${{ secrets.LINODEUSER }}
remote_key: ${{ secrets.LINODESSHKEY }}

- name: Close Linode Cloud Firewall for GH
if: (steps.deploy.outcome == 'success') || (steps.deploy.outcome == 'failed' || steps.deploy.outcome == 'skipped')
id: linode-fw-close
run: |
bash ./linode.sh -d --verbose
4 changes: 2 additions & 2 deletions src/layouts/DefaultLayout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ const {
<!-- head -->
<script
type="text/partytown"
src="https://www.googletagmanager.com/gtag/js?id={GA_ID}">
src="https://www.googletagmanager.com/gtag/js?id={GA-ID}">
</script>
<script type="text/partytown">
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag("js", new Date());
gtag("config", "{GA_ID}");
gtag("config", "{GA-ID}");
</script>
<!-- more head -->

Expand Down

0 comments on commit 256b7b5

Please sign in to comment.