diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..2808628 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,52 @@ +name: Build and Deploy + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install Nix + uses: cachix/install-nix-action@v31 + with: + nix_path: nixpkgs=channel:nixos-unstable + extra_nix_config: | + experimental-features = nix-command flakes + + - name: Build site (pull request) + if: github.event_name == 'pull_request' + run: | + # Update base URL for PR preview + sed -i "s|base_url = \"https://www.softinio.com\"|base_url = \"https://${{ github.head_ref }}.softinio.com\"|" ./config.toml + nix build + nix flake show + ls result + + - name: Deploy to Cloudflare Pages (pull request) + if: github.event_name == 'pull_request' + run: | + nix develop --command wrangler pages deploy result --branch=${{ github.head_ref }} --project-name=softinio --commit-dirty=true + env: + CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} + + - name: Build site (main branch) + if: github.ref == 'refs/heads/main' && github.event_name == 'push' + run: | + nix build + + - name: Deploy to Cloudflare Pages (main branch) + if: github.ref == 'refs/heads/main' && github.event_name == 'push' + run: | + nix develop --command wrangler pages deploy result --project-name=softinio --commit-dirty=true + env: + CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} \ No newline at end of file diff --git a/.woodpecker.yml b/.woodpecker.yml deleted file mode 100644 index 3aa04b0..0000000 --- a/.woodpecker.yml +++ /dev/null @@ -1,35 +0,0 @@ -steps: - - name: build - image: nixos/nix - commands: - - echo 'experimental-features = flakes nix-command' >> /etc/nix/nix.conf - - nix profile install nixpkgs#gnused --impure - - sed -i "s|base_url = \"https://www.softinio.com\"|base_url = \"https://$CI_COMMIT_BRANCH.softinio.com\"|" ./config.toml - - nix build - - nix flake show - - ls result - - nix develop --command wrangler pages deploy result --branch=$CI_COMMIT_BRANCH --project-name=softinio --commit-dirty=true - environment: - CLOUDFLARE_ACCOUNT_ID: - from_secret: cloudflare_account_id - CLOUDFLARE_API_TOKEN: - from_secret: cloudflare_api_token - when: - event: [push] - branch: - exclude: [ main ] - - - name: deploy - image: nixos/nix - commands: - - echo 'experimental-features = flakes nix-command' >> /etc/nix/nix.conf - - nix build - - nix develop --command wrangler pages deploy result --project-name=softinio --commit-dirty=true - environment: - CLOUDFLARE_ACCOUNT_ID: - from_secret: cloudflare_account_id - CLOUDFLARE_API_TOKEN: - from_secret: cloudflare_api_token - when: - event: push - branch: main diff --git a/README.md b/README.md index a2dd144..48a920a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![status-badge](https://ci.softinio.com/api/badges/1/status.svg)](https://ci.softinio.com/repos/1) +[![Build and Deploy](https://github.com/softinio/softinio.com/actions/workflows/deploy.yml/badge.svg)](https://github.com/softinio/softinio.com/actions/workflows/deploy.yml) # softinio.com Personal Blog of Salar Rahmanian, https://www.softinio.com