Skip to content

chore: version packages #1

chore: version packages

chore: version packages #1

Workflow file for this run

name: webpack-vue3-cicd
on:
push:
tags:
- 'webpack-vue3@*'
env:
SSH_PRIVATE_KEY: ${{secrets.SSH_PRIVATE_KEY}}
jobs:
extract:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.extract_version.outputs.version }}
steps:
- id: extract_version
run: |
echo "version=$(echo ${{ github.ref_name }} | sed 's/webpack-vue3@//')" >> $GITHUB_OUTPUT
build:
needs: extract
runs-on: ubuntu-latest
env:
IMAGE_VERSION: ${{ needs.extract.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build & Push Image
run: |
echo "${{env.IMAGE_VERSION}}"
docker login --username=${{secrets.DOCKER_USERNAME}} --password=${{secrets.DOCKER_PASSWORD}} ${{secrets.DOCKER_REGISTRY}}
docker build --target webpack-vue3-frontend -t ${{secrets.DOCKER_REGISTRY}}/${{secrets.DOCKER_NAMESPACE}}/fullstack-blog-webpack-vue3:${{env.IMAGE_VERSION}} .
docker push ${{secrets.DOCKER_REGISTRY}}/${{secrets.DOCKER_NAMESPACE}}/fullstack-blog-webpack-vue3:${{env.IMAGE_VERSION}}
deploy:
needs: [extract, build]
runs-on: ubuntu-latest
env:
IMAGE_VERSION: ${{ needs.extract.outputs.version }}
steps:
- name: SSH Auth && Deploy Image
run: |
ssh -V
mkdir -p ~/.ssh
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
cat >>~/.ssh/config <<END
Host remote
HostName ${{secrets.SSH_HOST}}
Port 22
User ${{secrets.SSH_USERNAME}}
IdentityFile ~/.ssh/id_rsa
StrictHostKeyChecking no
END
cat >>~/remote.sh <<END
docker ps
docker login --username=${{secrets.DOCKER_USERNAME}} --password=${{secrets.DOCKER_PASSWORD}} ${{secrets.DOCKER_REGISTRY}}
docker pull ${{secrets.DOCKER_REGISTRY}}/${{secrets.DOCKER_NAMESPACE}}/fullstack-blog-webpack-vue3:${{env.IMAGE_VERSION}}
cd ${{secrets.PROJECT_DIR}}
sed -i 's/^WEBPACK_VUE3_VERSION=.*/WEBPACK_VUE3_VERSION=${{env.IMAGE_VERSION}}/' .env.docker.local
docker compose --env-file .env.docker.local up -d
echo "Done"
END
ssh remote < ~/remote.sh