diff --git a/.github/disabled/dev.yaml b/.github/disabled/dev.yaml new file mode 100644 index 0000000..81763d0 --- /dev/null +++ b/.github/disabled/dev.yaml @@ -0,0 +1,108 @@ +name: "Dev" + +on: + workflow_dispatch: + push: + #branches-ignore: ["master"] + paths: + - ".github/workflows/dev.yaml" + - ".vitepress/**" + - "docs/**" + - "package*.json" + +env: + SSH_HOST: ${{ secrets.DEV_DEPLOY_HOST }} + SSH_PORT: ${{ secrets.DEV_DEPLOY_PORT }} + SSH_USER: ${{ secrets.DEV_DEPLOY_USER }} + SSH_PASS: ${{ secrets.DEV_DEPLOY_PASS }} + SSH_DEST: /static + +concurrency: + group: dev + cancel-in-progress: true + +jobs: + build: + name: "Build" + runs-on: ubuntu-latest + timeout-minutes: 10 + + if: ${{ !contains(github.event.head_commit.message, '#nodev') }} + + steps: + - name: "Checkout" + uses: actions/checkout@v5 + with: + fetch-depth: 0 + + - name: "Debug CTX github" + continue-on-error: true + env: + GITHUB_CTX: ${{ toJSON(github) }} + run: echo "$GITHUB_CTX" + + - name: "Setup Node 24" + uses: actions/setup-node@v6 + with: + node-version: 24 + + - name: "Install Dependencies" + run: | + npm ci + + - name: "Run Build" + run: | + npm run build + + - name: "Upload Artifact" + uses: actions/upload-artifact@v4 + with: + name: "artifact" + path: .vitepress/dist + + deploy: + name: "Deploy" + runs-on: ubuntu-latest + timeout-minutes: 5 + needs: build + + environment: + name: dev + url: https://dev-static.cssnr.com/ + + steps: + - name: "Download Artifact" + uses: actions/download-artifact@v5 + with: + name: "artifact" + + - name: "Debug Artifact" + continue-on-error: true + run: | + tree . + + - name: "No Robots" + run: | + cat < robots.txt + User-agent: * + Disallow: / + EOF + + - name: "Setup SSH" + run: | + mkdir -p "${HOME}/.ssh" && chmod 0700 "${HOME}/.ssh" + ssh-keyscan -p "${{ env.SSH_PORT }}" -H "${{ env.SSH_HOST }}" \ + | tee -a "${HOME}/.ssh/known_hosts" + + - name: "Deploy Artifact" + env: + SSHPASS: ${{ env.SSH_PASS }} + run: | + sshpass -e rsync -aPvh --delete -e 'ssh -p ${{ env.SSH_PORT }}' \ + ./ "${{ env.SSH_USER }}"@"${{ env.SSH_HOST }}":"${{ env.SSH_DEST }}" + + - name: "Send Discord Notification" + uses: sarisia/actions-status-discord@v1 + with: + webhook: ${{ secrets.DISCORD_WEBHOOK }} + description: "https://dev-static.cssnr.com/" diff --git a/.github/disabled/pages.yaml b/.github/disabled/pages.yaml new file mode 100644 index 0000000..1a00774 --- /dev/null +++ b/.github/disabled/pages.yaml @@ -0,0 +1,122 @@ +name: "Pages" + +on: + workflow_dispatch: + #push: + # branches: ["master"] + # paths: + # - ".github/workflows/pages.yaml" + # - ".vitepress/**" + # - "docs/**" + # - "package*.json" + +env: + crawler-id: "7a46f2b7-7169-4936-986d-21391c3134d4" + purge-domain: "" + +concurrency: + group: pages + cancel-in-progress: false + +jobs: + build: + name: "Build" + runs-on: ubuntu-latest + timeout-minutes: 10 + + if: ${{ !contains(github.event.head_commit.message, '#nodeploy') }} + + steps: + - name: "Checkout" + uses: actions/checkout@v5 + with: + fetch-depth: 0 + + - name: "Debug CTX github" + continue-on-error: true + env: + GITHUB_CTX: ${{ toJSON(github) }} + run: echo "$GITHUB_CTX" + + - name: "Setup Node 24" + uses: actions/setup-node@v6 + with: + node-version: 24 + + - name: "Configure Pages" + uses: actions/configure-pages@v5 + + - name: "Install Dependencies" + run: | + npm ci + + - name: "Run Build" + run: | + npm run build + + - name: "Upload Pages Artifact" + uses: actions/upload-pages-artifact@v4 + with: + path: .vitepress/dist + + - name: "Send Failure Notification" + if: ${{ failure() }} + uses: sarisia/actions-status-discord@v1 + with: + webhook: ${{ secrets.DISCORD_WEBHOOK }} + + deploy: + name: "Deploy" + runs-on: ubuntu-latest + timeout-minutes: 5 + needs: build + + permissions: + pages: write + id-token: write + + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + + steps: + - name: "Deploy Pages" + id: deployment + uses: actions/deploy-pages@v4 + + - name: "Send Deploy Notification" + if: ${{ !cancelled() }} + continue-on-error: true + uses: sarisia/actions-status-discord@v1 + with: + webhook: ${{ secrets.DISCORD_WEBHOOK }} + description: ${{ steps.deployment.outputs.page_url }} + + post: + name: "Post-Deploy" + runs-on: ubuntu-latest + timeout-minutes: 5 + needs: deploy + + steps: + - name: "Purge Cache" + if: ${{ env.purge-domain != '' }} + uses: cssnr/cloudflare-purge-cache-action@v2 + with: + zones: ${{ env.purge-domain }} + token: ${{ secrets.CLOUDFLARE_API_TOKEN }} + + - name: "Algolia Crawler" + if: ${{ env.crawler-id != '' }} + uses: cssnr/algolia-crawler-action@v1 + with: + crawler_id: ${{ env.crawler-id }} + crawler_user_id: ${{ secrets.CRAWLER_USER_ID }} + crawler_api_key: ${{ secrets.CRAWLER_API_KEY }} + + - name: "Send Post-Deploy Notification" + if: ${{ failure() }} + uses: sarisia/actions-status-discord@v1 + with: + webhook: ${{ secrets.DISCORD_WEBHOOK }} + description: ${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }} diff --git a/.github/workflows/dev.yaml b/.github/workflows/dev.yaml index 81763d0..1c18eac 100644 --- a/.github/workflows/dev.yaml +++ b/.github/workflows/dev.yaml @@ -3,106 +3,43 @@ name: "Dev" on: workflow_dispatch: push: - #branches-ignore: ["master"] + branches-ignore: [master] paths: - ".github/workflows/dev.yaml" - ".vitepress/**" - "docs/**" - "package*.json" -env: - SSH_HOST: ${{ secrets.DEV_DEPLOY_HOST }} - SSH_PORT: ${{ secrets.DEV_DEPLOY_PORT }} - SSH_USER: ${{ secrets.DEV_DEPLOY_USER }} - SSH_PASS: ${{ secrets.DEV_DEPLOY_PASS }} - SSH_DEST: /static - concurrency: - group: dev + group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: build: name: "Build" - runs-on: ubuntu-latest - timeout-minutes: 10 - if: ${{ !contains(github.event.head_commit.message, '#nodev') }} - - steps: - - name: "Checkout" - uses: actions/checkout@v5 - with: - fetch-depth: 0 - - - name: "Debug CTX github" - continue-on-error: true - env: - GITHUB_CTX: ${{ toJSON(github) }} - run: echo "$GITHUB_CTX" - - - name: "Setup Node 24" - uses: actions/setup-node@v6 - with: - node-version: 24 - - - name: "Install Dependencies" - run: | - npm ci - - - name: "Run Build" - run: | - npm run build - - - name: "Upload Artifact" - uses: actions/upload-artifact@v4 - with: - name: "artifact" - path: .vitepress/dist + uses: cssnr/workflows/.github/workflows/npm-build.yaml@master + permissions: + contents: read + with: + build: "npm run build" + path: ".vitepress/dist" + secrets: + webhook: ${{ secrets.DISCORD_WEBHOOK }} deploy: name: "Deploy" - runs-on: ubuntu-latest - timeout-minutes: 5 + uses: cssnr/workflows/.github/workflows/deploy-static.yaml@master needs: build - - environment: - name: dev - url: https://dev-static.cssnr.com/ - - steps: - - name: "Download Artifact" - uses: actions/download-artifact@v5 - with: - name: "artifact" - - - name: "Debug Artifact" - continue-on-error: true - run: | - tree . - - - name: "No Robots" - run: | - cat < robots.txt - User-agent: * - Disallow: / - EOF - - - name: "Setup SSH" - run: | - mkdir -p "${HOME}/.ssh" && chmod 0700 "${HOME}/.ssh" - ssh-keyscan -p "${{ env.SSH_PORT }}" -H "${{ env.SSH_HOST }}" \ - | tee -a "${HOME}/.ssh/known_hosts" - - - name: "Deploy Artifact" - env: - SSHPASS: ${{ env.SSH_PASS }} - run: | - sshpass -e rsync -aPvh --delete -e 'ssh -p ${{ env.SSH_PORT }}' \ - ./ "${{ env.SSH_USER }}"@"${{ env.SSH_HOST }}":"${{ env.SSH_DEST }}" - - - name: "Send Discord Notification" - uses: sarisia/actions-status-discord@v1 - with: - webhook: ${{ secrets.DISCORD_WEBHOOK }} - description: "https://dev-static.cssnr.com/" + permissions: + contents: read + with: + name: "dev" + url: "https://dev-static.cssnr.com/" + robots: true + secrets: + host: ${{ secrets.DEV_DEPLOY_HOST }} + port: ${{ secrets.DEV_DEPLOY_PORT }} + user: ${{ secrets.DEV_DEPLOY_USER }} + pass: ${{ secrets.DEV_DEPLOY_PASS }} + webhook: ${{ secrets.DISCORD_WEBHOOK }} diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index fb4dd7e..718e17b 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -7,12 +7,16 @@ on: push: branches: [master] +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: lint: name: "Lint" + if: ${{ !contains(github.event.head_commit.message, '#nolint') }} runs-on: ubuntu-latest timeout-minutes: 5 - if: ${{ !contains(github.event.head_commit.message, '#nolint') }} steps: - name: "Checkout" diff --git a/.github/workflows/pages.yaml b/.github/workflows/pages.yaml index 1a00774..4e45abd 100644 --- a/.github/workflows/pages.yaml +++ b/.github/workflows/pages.yaml @@ -2,68 +2,33 @@ name: "Pages" on: workflow_dispatch: - #push: - # branches: ["master"] - # paths: - # - ".github/workflows/pages.yaml" - # - ".vitepress/**" - # - "docs/**" - # - "package*.json" + push: + branches: [master] + paths: + - ".github/workflows/pages.yaml" + - ".vitepress/**" + - "docs/**" + - "package*.json" env: crawler-id: "7a46f2b7-7169-4936-986d-21391c3134d4" purge-domain: "" concurrency: - group: pages - cancel-in-progress: false + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true jobs: build: name: "Build" - runs-on: ubuntu-latest - timeout-minutes: 10 - if: ${{ !contains(github.event.head_commit.message, '#nodeploy') }} - - steps: - - name: "Checkout" - uses: actions/checkout@v5 - with: - fetch-depth: 0 - - - name: "Debug CTX github" - continue-on-error: true - env: - GITHUB_CTX: ${{ toJSON(github) }} - run: echo "$GITHUB_CTX" - - - name: "Setup Node 24" - uses: actions/setup-node@v6 - with: - node-version: 24 - - - name: "Configure Pages" - uses: actions/configure-pages@v5 - - - name: "Install Dependencies" - run: | - npm ci - - - name: "Run Build" - run: | - npm run build - - - name: "Upload Pages Artifact" - uses: actions/upload-pages-artifact@v4 - with: - path: .vitepress/dist - - - name: "Send Failure Notification" - if: ${{ failure() }} - uses: sarisia/actions-status-discord@v1 - with: - webhook: ${{ secrets.DISCORD_WEBHOOK }} + uses: cssnr/workflows/.github/workflows/npm-build.yaml@master + permissions: + contents: read + with: + build: "npm run build" + path: ".vitepress/dist" + pages: true deploy: name: "Deploy" @@ -114,7 +79,7 @@ jobs: crawler_user_id: ${{ secrets.CRAWLER_USER_ID }} crawler_api_key: ${{ secrets.CRAWLER_API_KEY }} - - name: "Send Post-Deploy Notification" + - name: "Send Discord Notification" if: ${{ failure() }} uses: sarisia/actions-status-discord@v1 with: diff --git a/.vitepress/theme/components/LatestVersion.vue b/.vitepress/theme/components/LatestVersion.vue new file mode 100644 index 0000000..da5940c --- /dev/null +++ b/.vitepress/theme/components/LatestVersion.vue @@ -0,0 +1,105 @@ + + + + + diff --git a/.vitepress/theme/index.js b/.vitepress/theme/index.js index 7740946..28f9454 100644 --- a/.vitepress/theme/index.js +++ b/.vitepress/theme/index.js @@ -3,6 +3,7 @@ import './custom.css' import 'virtual:group-icons.css' import StackTable from './components/StackTable.vue' +import LatestVersion from './components/LatestVersion.vue' import YouTubeEmbed from './components/YouTubeEmbed.vue' import CopyButton from '@cssnr/vitepress-plugin-copybutton' @@ -22,6 +23,7 @@ export default { app.component('Badge', VPBadge) app.component('StackTable', StackTable) + app.component('LatestVersion', LatestVersion) app.component('YouTubeEmbed', YouTubeEmbed) app.component('CB', CopyButton) diff --git a/.vitepress/vars.js b/.vitepress/vars.js index 44ec369..3bbe42f 100644 --- a/.vitepress/vars.js +++ b/.vitepress/vars.js @@ -17,6 +17,7 @@ export const repos = [ ['TapTap21/docker-remote-deployment-action', 3], ['kitconcept/docker-stack-deploy', 2], ['serversideup/github-action-docker-swarm-deploy', 2], + ['FarisZR/docker-compose-gitops-action', 2], ['matchory/docker-swarm-deployment-action', 2], ['matiasnu/github-action-ssh-docker-compose', 1], ['chaplyk/docker-compose-remote-action', 1], diff --git a/docs/guides/features.md b/docs/guides/features.md index 8d54a32..8c02da0 100644 --- a/docs/guides/features.md +++ b/docs/guides/features.md @@ -18,8 +18,6 @@ You can [get started here](get-started.md) or view [workflow examples](examples. If you need more options, please [open a feature request](https://github.com/cssnr/stack-deploy-action/discussions/categories/feature-requests) ::: - - ## Remote Context This action uses a [remote context](https://docs.docker.com/engine/manage-resources/contexts/) @@ -51,6 +49,10 @@ steps: ::: +_If you need to run multiple docker commands check out the new [Docker Context Action](https://actions.cssnr.com/docker-context/)._ + + + ## Job Summary Unless disabled, a Job Summary is generated to capture the command, output and errors. diff --git a/docs/guides/get-started.md b/docs/guides/get-started.md index a1361e1..9c7249b 100644 --- a/docs/guides/get-started.md +++ b/docs/guides/get-started.md @@ -12,7 +12,8 @@ To get started, create or update your [workflow file](#workflow) and review the _You can also view the [features](features.md) and additional [examples](examples.md)._ - +If you need to run multiple docker commands see the [Docker Context](#docker-context) Action. +You can also deploy directly to [Portainer](#portainer). ## Workflow @@ -32,7 +33,7 @@ and [pass](../docs/inputs.md#pass) or [ssh_key](../docs/inputs.md#ssh_key) _(not Check out the [Rolling Tags](features.md#rolling-tags) for more tag options, however `@v1` is recommended. -[![Latest Version](https://img.shields.io/github/v/release/cssnr/stack-deploy-action?style=for-the-badge&logo=github&label=Latest%20Release)](https://github.com/cssnr/stack-deploy-action/releases) +
@@ -101,11 +102,19 @@ If working within an [GitHub Organization](https://docs.github.com/en/organizati you can create these secrets in the organization and make them available to all your repositories. _This is why I use the [cssnr](https://github.com/cssnr) organization._ +## Docker Context + +This action creates a docker context in the current workflow to run any docker commands. + + + +More details on the website: https://actions.cssnr.com/docker-context + ## Portainer If you use Portainer, you should deploy directly to [Portainer](https://www.portainer.io/resources/get-started/install) for full control. -For this you should use: [cssnr/portainer-stack-deploy-action](https://github.com/cssnr/portainer-stack-deploy-action) +For this you should use [cssnr/portainer-stack-deploy-action](https://github.com/cssnr/portainer-stack-deploy-action). - https://github.com/marketplace/actions/portainer-stack-deploy-action