name: build on: push: branches: [main, staging] jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: docker/build-push-action@v5 with: context: . push: false load: true tags: git.stanrunge.dev/stan/personal-website:${{ github.sha }} deploy: needs: build runs-on: ubuntu-latest steps: - name: setup key run: | mkdir -p ~/.ssh echo "${{ secrets.DEPLOY_KEY }}" > ~/.ssh/id_ed25519 chmod 600 ~/.ssh/id_ed25519 ssh-keyscan -H 172.17.0.1 >> ~/.ssh/known_hosts - name: pick target run: | if [ "${{ github.ref_name }}" = "main" ]; then echo "DIR=/opt/personal-website" >> $GITHUB_ENV else echo "DIR=/opt/personal-website-staging" >> $GITHUB_ENV fi - name: deploy run: | ssh deploy@172.17.0.1 "echo IMAGE_TAG=${{ github.sha }} | sudo tee $DIR/.env && sudo docker compose -f $DIR/compose.prod.yml up -d"