feat: change to swarm running #18
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build | |
on: | |
workflow_dispatch: | |
push: | |
tags: | |
- "*" | |
env: | |
DOCKER_HOST: ssh://root@darkbot | |
jobs: | |
build: | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install Task | |
run: | | |
sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d -b /usr/local/bin | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: '^1.22.5' | |
# SOURCE_NAME: The branch or the tag | |
# SOURCE_BRANCH: The branch or empty | |
# SOURCE_TAG: The tag or empty | |
- name: Find tags | |
id: data | |
run: | | |
echo "BUILD_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT | |
echo "SOURCE_NAME=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT | |
echo "SOURCE_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT | |
echo "SOURCE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT | |
- name: Echo tags | |
run: | | |
echo ${{ steps.data.outputs.BUILD_VERSION }} | |
- name: Docker login | |
run: echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login --username darkwind8 --password-stdin | |
- name: Install ssh key | |
run: | | |
mkdir ~/.ssh | true | |
echo "${{ secrets.SSH_KEY_BASE64 }}" | base64 --decode > ~/.ssh/id_rsa | |
echo "Host darkbot" > ~/.ssh/config | |
echo " HostName 37.27.207.42" >> ~/.ssh/config | |
echo " User root" >> ~/.ssh/config | |
echo " IdentityFile ~/.ssh/id_rsa" >> ~/.ssh/config | |
echo " IdentitiesOnly yes" >> ~/.ssh/config | |
chmod 700 ~/.ssh | |
chmod 600 ~/.ssh/* | |
ssh-keyscan -H 37.27.207.42 >> ~/.ssh/known_hosts | true | |
ssh-keyscan -H darkbot >> ~/.ssh/known_hosts | true | |
- name: Build image | |
run: docker build --build-arg "BUILD_VERSION=${{ steps.data.outputs.BUILD_VERSION }}" --tag darkwind8/darkbot:${{ steps.data.outputs.BUILD_VERSION }} . | |
- name: Push image | |
run: | | |
docker push darkwind8/darkbot:${{ steps.data.outputs.BUILD_VERSION }} | |
docker tag darkwind8/darkbot:${{ steps.data.outputs.BUILD_VERSION }} darkwind8/darkbot:staging | |
docker push darkwind8/darkbot:staging | |
- name: Switch service image to new one | |
run: | | |
docker pull darkwind8/darkbot:staging && docker service update --image darkwind8/darkbot:staging darkbot-staging | |
# this stuff is for Docker mode only | |
# - name: Install arm64 redock at server (not amd64 in my case) | |
# run: ssh root@darkbot 'curl -L $(curl -Ls -o /dev/null -w %{url_effective} https://github.com/darklab8/redock/releases/latest | sed "s/releases\/tag/releases\/download/")/redock-linux-arm64 -o /usr/local/bin/redock && chmod 777 /usr/local/bin/redock' | |
# - name: Run redock # for docker mod only needed | |
# run: ssh root@darkbot 'redock --ctr=darkbot-staging --strict_pull=true --image_name=darkwind8/darkbot:${{ steps.data.outputs.BUILD_VERSION }}' |