@@ -9,73 +9,62 @@ concurrency:
99
1010jobs :
1111 deploy :
12+ name : Deploy Server
1213 runs-on : ubuntu-latest
1314
1415 steps :
1516 - name : 🛎️ Checkout Repository
1617 uses : actions/checkout@v4
1718
18- - name : 🔐 SSH Key & .env setup
19- run : |
20- mkdir -p ~/.ssh
21- chmod 700 ~/.ssh
22- echo "${{ secrets.SSH_SECRET }}" > ~/.ssh/bitanon.pem
23- chmod 600 ~/.ssh/bitanon.pem
24- echo "${{ secrets.ENV_FILE }}" > .env
25-
26- # - name: 🐳 Build Docker Image
27- # run: docker build -t lncrawl .
19+ - name : 🔐 Login to GitHub Container Registry
20+ uses : docker/login-action@v3
21+ with :
22+ registry : ghcr.io
23+ username : ${{ github.actor }}
24+ password : ${{ secrets.GITHUB_TOKEN }}
2825
2926 - name : 🐳 Set up Docker Buildx
3027 uses : docker/setup-buildx-action@v3
3128
32- - name : 💾 Docker Cache
33- uses : actions/cache@v4
34- with :
35- path : /tmp/.buildx-cache
36- key : ${{ runner.os }}-buildx-${{ github.sha }}
37- restore-keys : |
38- ${{ runner.os }}-buildx-
29+ - name : 📝 Create .env file for Docker build
30+ run : touch .env
3931
40- - name : 🐳 Build Docker Image with Cache
32+ - name : 🏗️ Build and push Container image
4133 uses : docker/build-push-action@v5
4234 with :
4335 context : .
44- tags : lncrawl:latest
36+ platforms : linux/amd64
37+ push : true
38+ tags : ghcr.io/${{ github.repository }}:latest
39+ labels : |
40+ org.opencontainers.image.source=${{ github.event.repository.html_url }}
41+ org.opencontainers.image.revision=${{ github.sha }}
4542 outputs : type=docker,dest=/tmp/lncrawl.tar
46- cache-from : type=local,src=/tmp/.buildx-cache
47- cache-to : type=local,dest=/tmp/.buildx-cache
43+ cache-from : type=gha
44+ cache-to : type=gha,mode=max
45+
46+ - name : 🛡️ Setup SSH Key
47+ run : |
48+ mkdir -p ~/.ssh
49+ chmod 700 ~/.ssh
50+ echo "${{ secrets.SSH_SECRET }}" > ~/.ssh/id_rsa
51+ chmod 600 ~/.ssh/id_rsa
52+ ssh-keyscan -H "${{ secrets.DEPLOY_SERVER }}" >> ~/.ssh/known_hosts
4853
4954 - name : 📦 Transfer Docker Image
5055 run : |
51- bzip2 < /tmp/lncrawl.tar | \
52- ssh -i ~/.ssh/bitanon.pem -o StrictHostKeyChecking=no \
53- "${{ secrets.DEPLOY_SERVER }}" 'bunzip2 | docker load'
56+ bzip2 < /tmp/lncrawl.tar | ssh "${{ secrets.DEPLOY_SERVER }}" 'bunzip2 | docker load'
5457
55- # - name: 📦 Save and Transfer Docker Image
56- # run: |
57- # docker save lncrawl | bzip2 | \
58- # ssh -i ~/.ssh/bitanon.pem -o StrictHostKeyChecking=no \
59- # "${{ secrets.DEPLOY_SERVER }}" docker load
58+ - name : 📤 Upload Compose File
59+ run : |
60+ scp ./scripts/server-compose.yml "${{ secrets.DEPLOY_SERVER }}:~/lncrawl/compose.yml"
6061
61- - name : 🏗️ Prepare server environment
62+ - name : 🚀 Deploy over SSH
6263 run : |
63- ssh -i ~/.ssh/bitanon.pem -o StrictHostKeyChecking=no \
64- "${{ secrets.DEPLOY_SERVER }}" << 'EOF'
64+ ssh "${{ secrets.DEPLOY_SERVER }}" << 'EOF'
6565 mkdir -p ~/lncrawl/output_path
6666 cd ~/lncrawl
67- touch .env sqlite.db
68- chown 1000:1000 .env sqlite.db output_path
67+ touch .env
68+ chown 1000:1000 .env output_path
69+ docker compose -f ~/lncrawl/compose.yml up -d
6970 EOF
70-
71- - name : 📂 Upload Compose File
72- run : |
73- scp -i ~/.ssh/bitanon.pem -o StrictHostKeyChecking=no \
74- ./scripts/server-compose.yml \
75- "${{ secrets.DEPLOY_SERVER }}:~/lncrawl/compose.yml"
76-
77- - name : 🚀 Run Container via Docker Compose
78- run : |
79- ssh -i ~/.ssh/bitanon.pem -o StrictHostKeyChecking=no \
80- "${{ secrets.DEPLOY_SERVER }}" \
81- "docker compose -f ~/lncrawl/compose.yml up -d"
0 commit comments