From 8189599e9a4a1ab65cfe091463d3a7ebfc43a5b3 Mon Sep 17 00:00:00 2001
From: Yordis Prieto <yordis.prieto@gmail.com>
Date: Thu, 24 Oct 2024 12:15:41 -0400
Subject: [PATCH] feat: add hex publish docs github action

---
 templates/.github/workflows/production.yaml   |  5 +--
 templates/.github/workflows/publish-docs.yaml | 32 +++++++++++++++++++
 2 files changed, 35 insertions(+), 2 deletions(-)
 create mode 100644 templates/.github/workflows/publish-docs.yaml

diff --git a/templates/.github/workflows/production.yaml b/templates/.github/workflows/production.yaml
index 0c8311a..ce27bfe 100644
--- a/templates/.github/workflows/production.yaml
+++ b/templates/.github/workflows/production.yaml
@@ -12,8 +12,8 @@ on:
 concurrency:
   group: Production
 
-jobs:
 {{#if IS_MIX_PACKAGE}}
+jobs:
   Hex:
     runs-on: ubuntu-latest
 
@@ -33,5 +33,6 @@ jobs:
         run: mix hex.publish --yes
         env:
           HEX_API_KEY: $\{{ secrets.HEX_API_KEY }}
-
+{{else}}
+jobs: {}
 {{/if}}
diff --git a/templates/.github/workflows/publish-docs.yaml b/templates/.github/workflows/publish-docs.yaml
new file mode 100644
index 0000000..46bab11
--- /dev/null
+++ b/templates/.github/workflows/publish-docs.yaml
@@ -0,0 +1,32 @@
+# This file is synced with beam-community/common-config. Any changes will be overwritten.
+
+name: Publish Docs
+
+on:
+  workflow_dispatch:
+
+concurrency:
+  group: hex-publish-docs
+  cancel-in-progress: true
+
+{{#if IS_MIX_PACKAGE}}
+jobs:
+  Hex:
+    runs-on: ubuntu-latest
+    if: github.ref == 'refs/heads/main'
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v4
+
+      - name: Setup Elixir
+        uses: stordco/actions-elixir/setup@v1
+        with:
+          github-token: $\{{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
+
+      - name: Publish Docs
+        run: mix hex.publish docs --yes
+        env:
+          HEX_API_KEY: $\{{ secrets.HEX_API_KEY }}
+{{else}}
+jobs: {}
+{{/if}}