diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..dbe9dbdf --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,36 @@ +name: Deploy Portfolio + +# Controls when the workflow will run +on: + # Triggers the workflow on push or pull request events but only for the main branch + push: + branches: [ main ] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" + deploy: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + + # Saves the private key and adds your server to the list of known hosts + - name: SSH Setup + run: | + mkdir -p ~/.ssh/ + echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa + sudo chmod 600 ~/.ssh/id_rsa + echo "$SSH_HOST_THUMBPRINT" > ~/.ssh/known_hosts + shell: bash + env: + SSH_PRIVATE_KEY: ${{secrets.DBP_LOGIN_KEY}} + SSH_HOST_THUMBPRINT: ${{secrets.DBP_THUMBPRINT}} + + # Connects to your server via ssh and runs the deploy bash script + - name: Run Deploy Script + run: ssh -i ~/.ssh/id_rsa prod@${{secrets.IP_ADDRESS}} sh portfolio-deploy.sh diff --git a/.gitignore b/.gitignore index a547bf36..04d53208 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +.env +log.txt + # Logs logs *.log diff --git a/package-lock.json b/package-lock.json index aa339b14..25a88990 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,6 +13,7 @@ "@fortawesome/free-solid-svg-icons": "^6.7.2", "@fortawesome/react-fontawesome": "^0.2.2", "cors": "^2.8.5", + "dotenv": "^16.4.7", "express": "^4.21.2", "postmark": "^4.0.5", "react": "^18.2.0", @@ -1192,6 +1193,18 @@ "node": ">=8" } }, + "node_modules/dotenv": { + "version": "16.4.7", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.7.tgz", + "integrity": "sha512-47qPchRCykZC03FhkYAhrvwU4xDBFIj1QPqaarj6mdM/hgUzfPHcpkHJOn3mJAufFeeAxAzeGsr5X0M4k6fLZQ==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, "node_modules/dunder-proto": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", diff --git a/package.json b/package.json index e108ef8f..99c7dfff 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "@fortawesome/free-solid-svg-icons": "^6.7.2", "@fortawesome/react-fontawesome": "^0.2.2", "cors": "^2.8.5", + "dotenv": "^16.4.7", "express": "^4.21.2", "postmark": "^4.0.5", "react": "^18.2.0", @@ -24,5 +25,6 @@ "build": "vite build", "dev": "vite --host", "start": "vite --host" - } + }, + "type": "module" } diff --git a/src/Home.jsx b/src/Home.jsx index 1b39ed65..c5cea31f 100644 --- a/src/Home.jsx +++ b/src/Home.jsx @@ -32,7 +32,7 @@ const Home = ({ image, skills }) => {