First official commit
This commit is contained in:
@@ -13,31 +13,65 @@ jobs:
|
||||
# URL of the repository to clone
|
||||
TEMPLATE_REPO_URL: https://git.aranroig.com/Syndria98/dnd-vault-template.git
|
||||
# Folder name inside the target repo where this repo's contents will be placed
|
||||
TARGET_SUBFOLDER: my-repo-contents
|
||||
TARGET_SUBFOLDER: template/content
|
||||
VAULT_NAME: test-campaign
|
||||
|
||||
steps:
|
||||
- name: Checkout current repository
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
path: current-repo
|
||||
path: current
|
||||
|
||||
- name: Install SSH client
|
||||
run: |
|
||||
apt-get update -y && apt-get install -y openssh-client
|
||||
|
||||
- name: Setup SSH inside container
|
||||
run: |
|
||||
mkdir -p ~/.ssh
|
||||
echo "${{ secrets.DEPLOY_KEY }}" > ~/.ssh/id_ed25519
|
||||
chmod 600 ~/.ssh/id_ed25519
|
||||
|
||||
# Add the container host to known_hosts
|
||||
ssh-keyscan -H ${{ secrets.DEPLOY_HOST }} >> ~/.ssh/known_hosts
|
||||
|
||||
- name: Log in to registry
|
||||
run: |
|
||||
echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login git.aranroig.com -u "${{ secrets.REGISTRY_USER }}" --password-stdin
|
||||
|
||||
- name: Clone target repository
|
||||
run: |
|
||||
git clone "$TEMPLATE_REPO_URL" target-repo
|
||||
git clone "$TEMPLATE_REPO_URL" target
|
||||
|
||||
- name: Copy current repo contents into target subfolder
|
||||
run: |
|
||||
mkdir -p target-repo/$TARGET_SUBFOLDER
|
||||
rm -R target/$TARGET_SUBFOLDER
|
||||
mkdir -p target/$TARGET_SUBFOLDER
|
||||
# Exclude the .git directory from the copy
|
||||
rsync -av --exclude='.git' current-repo/ target-repo/$TARGET_SUBFOLDER/
|
||||
rsync -av --exclude={.git,.obsidian,.gitea} current/content/ target/$TARGET_SUBFOLDER/
|
||||
|
||||
- name: List result (dry run verification)
|
||||
- name: Build frontend
|
||||
run: |
|
||||
echo "=== Contents of target repo after copy ==="
|
||||
find target-repo -not -path '*/.git/*' | sort
|
||||
docker build -t git.aranroig.com/${{ secrets.REGISTRY_USER }}/vault-$VAULT_NAME:latest ./target/template
|
||||
docker push git.aranroig.com/${{ secrets.REGISTRY_USER }}/vault-$VAULT_NAME:latest
|
||||
|
||||
- name: Upload result as artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: target-repo-with-contents
|
||||
path: target-repo/
|
||||
- name: Generate docker compose .env
|
||||
run: |
|
||||
cat > ./target/.env << EOF
|
||||
VAULT_NAME=$VAULT_NAME
|
||||
EOF
|
||||
|
||||
- name: Copy files
|
||||
run: |
|
||||
scp ./target/docker-compose.yml deploy@${{ secrets.DEPLOY_HOST}}:/var/www/app/
|
||||
scp ./target/nginx.conf deploy@${{ secrets.DEPLOY_HOST }}:/var/www/app/nginx.conf
|
||||
scp ./target/.env deploy@${{ secrets.DEPLOY_HOST }}:/var/www/app/.env
|
||||
|
||||
- name: Deploy
|
||||
run: |
|
||||
ssh deploy@${{ secrets.DEPLOY_HOST }} << 'EOF'
|
||||
echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login git.aranroig.com -u "${{ secrets.REGISTRY_USER }}" --password-stdin
|
||||
cd /var/www/app/
|
||||
docker-compose pull
|
||||
docker-compose up -d
|
||||
EOF
|
||||
|
||||
Reference in New Issue
Block a user