-
-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automate docker image build and push to VPS #4
Comments
Hi @elgorditosalsero you could use this Github Action, by editing the last script if you do not want to use name: Deploy Node App with Docker
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Copy project to server
uses: appleboy/scp-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: 22
source: "."
target: ${{ secrets.TARGET_PATH }}
- name: Build and Run Docker Container on server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: 22
script: |
cd {{ secrets.TARGET_PATH }}
docker-compose up --build -d |
Thank you @fedy97! This is super nice and seems promising 😄 I need to understand how to handle env var too, but that's a starting point! |
If you already have a |
Yeah, but I'm referring to the .env for the project, I'd love to avoid to write it directly on the VPS, as if I want to make some changes, I always have to login there, but I can handle them via the secrets here would be probably be better 😄 I have to do some research about it |
@elgorditosalsero a brutal way of doing that would be to edit the last action in something like this - name: Build and Run Docker Container on server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: 22
script: |
cd ${{ secrets.TARGET_PATH }}
# Export your secrets as environment variables
export SECRET1="${{ secrets.SECRET1 }}"
export SECRET2="${{ secrets.SECRET2 }}"
docker-compose up --build -d or recreating the - name: Create .env file and Run Docker Container on server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: 22
script: |
cd ${{ secrets.TARGET_PATH }}
cat <<EOF > .env
SECRET1=${{ secrets.SECRET1 }}
SECRET2=${{ secrets.SECRET2 }}
EOF
docker-compose up --build -d so that all the secrets stored in github are exported each time a new deploy is triggered. Let's see if someone else has a smarter solution |
Automate docker image build and push to VPS
Description
Feature type
Idea
I'd love to automate the creation of the image when there are new merges into
main
to not have to deploy the bot manually and restart it via docker.Proposal
I'm looking for help 😄
Alternatives
Please tell me 😄
The text was updated successfully, but these errors were encountered: