|
| 1 | +name: Build and deploy |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - main |
| 6 | + workflow_dispatch: |
| 7 | +permissions: |
| 8 | + contents: read |
| 9 | +concurrency: |
| 10 | + group: pages |
| 11 | + cancel-in-progress: false |
| 12 | +defaults: |
| 13 | + run: |
| 14 | + shell: bash |
| 15 | +jobs: |
| 16 | + build: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + env: |
| 19 | + DART_SASS_VERSION: 1.93.2 |
| 20 | + GO_VERSION: 1.25.3 |
| 21 | + HUGO_VERSION: 0.152.2 |
| 22 | + NODE_VERSION: 22.20.0 |
| 23 | + TZ: Europe/Oslo |
| 24 | + steps: |
| 25 | + - name: Checkout |
| 26 | + uses: actions/checkout@v5 |
| 27 | + with: |
| 28 | + submodules: recursive |
| 29 | + fetch-depth: 0 |
| 30 | + - name: Setup Go |
| 31 | + uses: actions/setup-go@v5 |
| 32 | + with: |
| 33 | + go-version: ${{ env.GO_VERSION }} |
| 34 | + cache: false |
| 35 | + - name: Setup Node.js |
| 36 | + uses: actions/setup-node@v4 |
| 37 | + with: |
| 38 | + node-version: ${{ env.NODE_VERSION }} |
| 39 | + - name: Setup Pages |
| 40 | + id: pages |
| 41 | + uses: actions/configure-pages@v5 |
| 42 | + - name: Create directory for user-specific executable files |
| 43 | + run: | |
| 44 | + mkdir -p "${HOME}/.local" |
| 45 | + - name: Install Dart Sass |
| 46 | + run: | |
| 47 | + curl -sLJO "https://github.com/sass/dart-sass/releases/download/${DART_SASS_VERSION}/dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz" |
| 48 | + tar -C "${HOME}/.local" -xf "dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz" |
| 49 | + rm "dart-sass-${DART_SASS_VERSION}-linux-x64.tar.gz" |
| 50 | + echo "${HOME}/.local/dart-sass" >> "${GITHUB_PATH}" |
| 51 | + - name: Install Hugo |
| 52 | + run: | |
| 53 | + curl -sLJO "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.tar.gz" |
| 54 | + mkdir "${HOME}/.local/hugo" |
| 55 | + tar -C "${HOME}/.local/hugo" -xf "hugo_extended_${HUGO_VERSION}_linux-amd64.tar.gz" |
| 56 | + rm "hugo_extended_${HUGO_VERSION}_linux-amd64.tar.gz" |
| 57 | + echo "${HOME}/.local/hugo" >> "${GITHUB_PATH}" |
| 58 | + - name: Verify installations |
| 59 | + run: | |
| 60 | + echo "Dart Sass: $(sass --version)" |
| 61 | + echo "Go: $(go version)" |
| 62 | + echo "Hugo: $(hugo version)" |
| 63 | + echo "Node.js: $(node --version)" |
| 64 | + - name: Install Node.js dependencies |
| 65 | + run: | |
| 66 | + [[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true |
| 67 | + - name: Configure Git |
| 68 | + run: | |
| 69 | + git config core.quotepath false |
| 70 | + - name: Cache restore |
| 71 | + id: cache-restore |
| 72 | + uses: actions/cache/restore@v4 |
| 73 | + with: |
| 74 | + path: ${{ runner.temp }}/hugo_cache |
| 75 | + key: hugo-${{ github.run_id }} |
| 76 | + restore-keys: |
| 77 | + hugo- |
| 78 | + - name: Build the site |
| 79 | + run: | |
| 80 | + chmod +x build.sh && ./build.sh |
| 81 | + deploy: |
| 82 | + runs-on: ubuntu-latest |
| 83 | + needs: build |
| 84 | + steps: |
| 85 | + - name: Install SSH key |
| 86 | + uses: shimataro/ssh-key-action@v2 |
| 87 | + with: |
| 88 | + key: ${{ secrets.SSH_PRIVATE_KEY }} |
| 89 | + known_hosts: ${{ secrets.SSH_KNOWN_HOSTS }} |
| 90 | + - name: rsync over SSH |
| 91 | + run: rsync -e 'ssh -p 20200' -r ./public/ rsync@asie.pl:/var/www/domains/docs.asie.pl/nitroustracker/ |
0 commit comments