Navbar Update #103
Workflow file for this run
This file contains hidden or 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: Docker Frontend CI | |
| on: | |
| push: | |
| branches: [ "main" ] | |
| pull_request: | |
| branches: [ "main" ] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| timestamp: ${{ steps.timestamp.outputs.timestamp }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Get timestamp | |
| id: timestamp | |
| run: echo "timestamp=$(date +%s%3N)" >> $GITHUB_OUTPUT && echo "::set-output name=timestamp::$(date +%s%3N)" | |
| - name: Build the Docker image | |
| run: docker build . --file Dockerfile --tag techknowledge-front:${{ steps.timestamp.outputs.timestamp }} --build-arg VITE_API_URL=${{ secrets.PROD_API_URL }} | |
| - name: Login to Docker Hub | |
| run: echo "${{ secrets.DOCKER_HUB_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_HUB_USERNAME }}" --password-stdin | |
| - name: Tag the image | |
| run: docker tag techknowledge-front:${{ steps.timestamp.outputs.timestamp }} ${{ secrets.DOCKER_HUB_USERNAME }}/techknowledge-front:${{ steps.timestamp.outputs.timestamp }} | |
| - name: Push the image | |
| run: docker push ${{ secrets.DOCKER_HUB_USERNAME }}/techknowledge-front:${{ steps.timestamp.outputs.timestamp }} | |
| deploy: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: SSH into server and update frontend | |
| uses: appleboy/ssh-action@v1.2.0 | |
| with: | |
| host: ${{ secrets.PROD_SERVER_IP }} | |
| username: ${{ secrets.SERVER_USERNAME }} | |
| key: ${{ secrets.SERVER_PRIVATE_KEY }} | |
| script: | | |
| cd ~/projects/blog-techknowledge-front | |
| docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} -p ${{ secrets.DOCKER_HUB_PASSWORD }} | |
| docker pull mikkaiserdev/techknowledge-front:${{ needs.build.outputs.timestamp }} | |
| sed -i 's/^IMAGE_TAG=.*/IMAGE_TAG=${{ needs.build.outputs.timestamp }}/' .env | |
| docker compose down | |
| docker rm -f techknowledge-front-container | |
| docker compose up -d --force-recreate |