portfolio/.gitea/workflows/publish.yml

75 lines
2.6 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'
2024-08-22 16:18:05 +00:00
- name: Decrypt secrets
run: ./decrypt_secrets.sh
env:
SECRET_PASSPHRASE: ${{ secrets.SECRET_PASSPHRASE }}
2024-08-22 16:05:57 +00:00
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{secrets.DOCKER_HUB_USERNAME}}
password: ${{secrets.DOCKER_HUB_PASSWORD}}
- name: Set up Docker Buildx
uses: https://github.com/docker/setup-buildx-action@v3
with:
config-inline: |
[registry."docker.io"]
mirrors = ["mirror.gcr.io"]
2024-08-23 14:38:25 +00:00
# - name: Build and push Docker image
# uses: https://github.com/docker/build-push-action@v6
# with:
# context: .
# file: ./Dockerfile
# push: true
# tags: ${{secrets.DOCKER_HUB_USERNAME}}/portfolio:v1
- name: Build Docker image
run: |
2024-08-23 14:42:31 +00:00
DOCKER_BUILDKIT=1 docker build --secret id=SPOTIFY_CLIENT_ID,env=.env \
--secret id=SPOTIFY_CLIENT_SECRET,env=.env \
--secret id=SPOTIFY_REFRESH_TOKEN,env=.env \
--secret id=NEXT_PUBLIC_SITE_URL,env=.env \
--secret id=GITHUB_ACCESS_TOKEN,env=.env \
--secret id=GITHUB_USERNAME,env=.env \
--secret id=GITHUB_CLIENT_ID,env=.env \
--secret id=GITHUB_SECRET,env=.env \
--secret id=NEXT_PUBLIC_SUPABASE_URL,env=.env \
--secret id=NEXT_PUBLIC_SUPABASE_ANON_KEY,env=.env \
--secret id=SUPABASE_SERVICE_ROLE_KEY,env=.env \
2024-08-23 14:38:25 +00:00
-t ${{secrets.DOCKER_HUB_USERNAME}}/portfolio:v1 \
.
2024-08-23 14:20:51 +00:00
- name: Push the Docker image
run: |
docker image push ${{secrets.DOCKER_HUB_USERNAME}}/portfolio:v1
2024-08-22 16:05:57 +00:00
- name: Stop the docker container
continue-on-error: true
run: sudo docker stop portfolio
- name: Remove the docker container
continue-on-error: true
run: sudo docker rm portfolio
- name: Pull the Docker image
2024-08-22 20:04:35 +00:00
run: sudo docker pull ${{secrets.DOCKER_HUB_USERNAME}}/portfolio:v1
2024-08-22 16:05:57 +00:00
- name: Run the Docker container
2024-08-23 11:40:04 +00:00
run: sudo docker run -d --restart unless-stopped --env-file ./.env --name portfolio -p ${{vars.TAILSCALE_IP}}:3000:3000 ${{secrets.DOCKER_HUB_USERNAME}}/portfolio:v1