|
| 1 | +on: { push: { branches: [master,main,release,dev] } } |
| 2 | + |
| 3 | +jobs: |
| 4 | + deploy: |
| 5 | + runs-on: ubuntu-latest |
| 6 | + timeout-minutes: 20 |
| 7 | + env: |
| 8 | + DEPLOY_SERVER: ${{ secrets.DEPLOY_SERVER }} |
| 9 | + DEPLOY_USER: ${{ secrets.DEPLOY_USER }} |
| 10 | + DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }} |
| 11 | + # ssh-keygen -t ed25519 -C "github-actions-deploy" -f ~/.ssh/github_actions_deploy -N "" |
| 12 | + # cat ~/.ssh/github_actions_deploy.pub >> ~/.ssh/authorized_keys |
| 13 | + # chmod 600 ~/.ssh/authorized_keys |
| 14 | + # base64 -w 0 ~/.ssh/github_actions_deploy |
| 15 | + DOCKER_REGISTRY: ${{ secrets.DOCKER_REGISTRY }} |
| 16 | + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} |
| 17 | + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} |
| 18 | + |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@v4 |
| 21 | + - run: | |
| 22 | + sudo apt-get update |
| 23 | + sudo apt-get install -y --no-install-recommends ruby ruby-dev build-essential |
| 24 | + sudo gem install dry-stack:0.1.54 |
| 25 | +
|
| 26 | + - run: | |
| 27 | + test -n "$DEPLOY_SERVER" |
| 28 | + test -n "$DEPLOY_KEY" |
| 29 | + mkdir -p ~/.ssh |
| 30 | + echo "$DEPLOY_KEY" | base64 -d > ~/.ssh/id_rsa |
| 31 | + chmod 600 ~/.ssh/id_rsa |
| 32 | + printf 'Host *\n\tBatchMode yes\n\tStrictHostKeyChecking no\n' > ~/.ssh/config |
| 33 | + chmod 400 ~/.ssh/config |
| 34 | +
|
| 35 | + - run: | |
| 36 | + if [ -n "$DOCKER_USERNAME" ] && [ -n "$DOCKER_PASSWORD" ]; then |
| 37 | + registry="${DOCKER_REGISTRY:-docker.io}" |
| 38 | + echo "$DOCKER_PASSWORD" | docker login "$registry" -u "$DOCKER_USERNAME" --password-stdin |
| 39 | + else |
| 40 | + echo "Skipping Docker registry login; DOCKER_USERNAME or DOCKER_PASSWORD is not set." |
| 41 | + fi |
| 42 | +
|
| 43 | + - working-directory: stack |
| 44 | + run: | |
| 45 | + deploy_target="$DEPLOY_SERVER" |
| 46 | + if ! printf '%s' "$deploy_target" | grep -q '@'; then |
| 47 | + deploy_target="${DEPLOY_USER:-root}@${deploy_target}" |
| 48 | + fi |
| 49 | +
|
| 50 | + dry-stack swarm_deploy -x "ssh://${deploy_target}" -- --prune --resolve-image=always < ruby-mitm-proxy.drs |
0 commit comments