46 lines
1.3 KiB
YAML
46 lines
1.3 KiB
YAML
name: Deploy Website
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
- master
|
|
|
|
jobs:
|
|
build-and-deploy:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Check out repository code
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Build Docker image
|
|
run: |
|
|
docker build --pull -t akkolli-website:latest .
|
|
|
|
- name: Stop existing container
|
|
run: |
|
|
docker stop website-container || true
|
|
docker rm website-container || true
|
|
|
|
- name: Run new container
|
|
run: |
|
|
docker run -d \
|
|
--name website-container \
|
|
--restart unless-stopped \
|
|
-p 8083:80 \
|
|
akkolli-website:latest
|
|
|
|
- name: Purge Cloudflare cache
|
|
env:
|
|
CLOUDFLARE_ZONE_ID: ${{ secrets.CLOUDFLARE_ZONE_ID }}
|
|
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
|
run: |
|
|
if [ -n "$CLOUDFLARE_ZONE_ID" ] && [ -n "$CLOUDFLARE_API_TOKEN" ]; then
|
|
curl --fail --silent --show-error \
|
|
--request POST \
|
|
--url "https://api.cloudflare.com/client/v4/zones/$CLOUDFLARE_ZONE_ID/purge_cache" \
|
|
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
|
|
--header "Content-Type: application/json" \
|
|
--data '{"purge_everything":true}'
|
|
fi
|