portfolio/.gitea/workflows/publish.yml

56 lines
2.0 KiB
YAML
Raw Normal View History

2024-08-22 16:05:57 +00:00
name: Build And Publish
run-name: ${{ gitea.actor }} runs ci pipeline
on: [ push ]
jobs:
BuildAndPublish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: https://github.com/actions/checkout@v4
- name: Use Node.js
uses: https://github.com/actions/setup-node@v3
with:
node-version: '18.17.0'
- name: Decrypt secrets
run: ./decrypt_secrets.sh
env:
SECRET_PASSPHRASE: ${{ secrets.SECRET_PASSPHRASE }}
2024-08-28 14:28:37 +00:00
- name: Login to registry
2024-08-22 16:05:57 +00:00
uses: docker/login-action@v3
with:
2024-08-28 14:28:37 +00:00
registry: git.ryansnet.xyz
username: ${{secrets.REGISTRY_USERNAME}}
password: ${{secrets.REGISTRY_PASSWORD}}
2024-08-22 16:05:57 +00:00
- name: Set up Docker Buildx
uses: https://github.com/docker/setup-buildx-action@v3
with:
config-inline: |
2024-08-28 14:28:37 +00:00
[registry."${{secrets.REGISTRY_URL}}"]
2024-08-22 16:05:57 +00:00
2024-08-28 14:28:37 +00:00
- name: Build and tag image
run: |
docker build -t ${{secrets.REGISTRY_URL}}/${{secrets.REGISTRY_USERNAME}}/${{secrets.REPO_NAME}}:latest .
# docker tag ${{secrets.REGISTRY_URL}}/${{secrets.REGISTRY_USERNAME}}/${{secrets.REPO_NAME}}:latest ${{secrets.REGISTRY_URL}}/${{secrets.REGISTRY_USERNAME}}/${{secrets.REPO_NAME}}:latest
- name: Push image
run: docker push ${{secrets.REGISTRY_URL}}/${{secrets.REGISTRY_USERNAME}}/${{secrets.REPO_NAME}}:latest
2024-08-22 16:05:57 +00:00
2024-08-23 21:46:33 +00:00
- name: Stop and remove old Docker container
2024-08-22 16:05:57 +00:00
continue-on-error: true
2024-08-23 21:46:33 +00:00
run: |
sudo docker stop ${{vars.REPO_NAME}}
sudo docker rm ${{vars.REPO_NAME}}
- name: Pull new image and start Docker container
run: |
2024-08-28 14:28:37 +00:00
sudo docker pull ${{secrets.REGISTRY_URL}}/${{secrets.REGISTRY_USERNAME}}/${{vars.REPO_NAME}}:latest
2024-08-26 20:34:46 +00:00
sudo docker run -d --restart unless-stopped \
--env-file ./.env \
--name portfolio \
-p ${{vars.DEPLOY_IP}}:3000:3000 \
2024-08-28 14:28:37 +00:00
${{secrets.REGISTRY_URL}}/${{secrets.REGISTRY_USERNAME}}/${{vars.REPO_NAME}}:latest