Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/workflows/publish-x.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,57 @@ jobs:
persist-credentials: false
fetch-depth: 0

- name: Check X publisher configuration
id: x_config
shell: bash
env:
X_API_KEY: ${{ secrets.X_API_KEY }}
X_API_KEY_SECRET: ${{ secrets.X_API_KEY_SECRET }}
X_ACCESS_TOKEN: ${{ secrets.X_ACCESS_TOKEN }}
X_ACCESS_TOKEN_SECRET: ${{ secrets.X_ACCESS_TOKEN_SECRET }}
X_ACCOUNT_USER_ID: ${{ vars.X_ACCOUNT_USER_ID }}
run: |
set -euo pipefail

names=(
X_API_KEY
X_API_KEY_SECRET
X_ACCESS_TOKEN
X_ACCESS_TOKEN_SECRET
X_ACCOUNT_USER_ID
)
configured=0
missing=()

for name in "${names[@]}"; do
if [[ -n "${!name:-}" ]]; then
((configured += 1))
else
missing+=("$name")
fi
done

if ((configured == 0)); then
echo "enabled=false" >> "$GITHUB_OUTPUT"
echo "::notice::X publication is disabled because its protected environment has not been configured."
exit 0
fi

if ((${#missing[@]} != 0)); then
printf '::error::X publisher configuration is incomplete; missing: %s.\n' "${missing[*]}"
exit 1
fi

echo "enabled=true" >> "$GITHUB_OUTPUT"

- name: Setup .NET SDK
if: ${{ steps.x_config.outputs.enabled == 'true' }}
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
with:
global-json-file: global.json

- name: Resolve deployed publication boundary
if: ${{ steps.x_config.outputs.enabled == 'true' }}
id: publication
shell: bash
env:
Expand Down Expand Up @@ -144,6 +189,7 @@ jobs:
echo "deployed_revision=$deployed_revision" >> "$GITHUB_OUTPUT"

- name: Prepare durable publisher state worktree
if: ${{ steps.x_config.outputs.enabled == 'true' }}
id: state
shell: bash
env:
Expand All @@ -161,6 +207,7 @@ jobs:
echo "directory=$state_directory" >> "$GITHUB_OUTPUT"

- name: Publish and record receipts
if: ${{ steps.x_config.outputs.enabled == 'true' }}
env:
X_API_KEY: ${{ secrets.X_API_KEY }}
X_API_KEY_SECRET: ${{ secrets.X_API_KEY_SECRET }}
Expand All @@ -178,6 +225,7 @@ jobs:
--account-id "$X_ACCOUNT_USER_ID"

- name: Persist receipts and checkpoint
if: ${{ steps.x_config.outputs.enabled == 'true' }}
shell: bash
env:
GH_TOKEN: ${{ github.token }}
Expand Down
5 changes: 5 additions & 0 deletions X_PUBLISHING.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ modify `feed.xml`.
`automation/x-publisher-state` at the currently deployed revision. That first
run intentionally does not backfill the existing archive.

When all five settings are absent, automatic publication reports a notice and
exits successfully so the optional integration does not make documentation
publication appear to fail. A partially configured environment fails with the
names of the missing settings; it never silently disables a broken live setup.

Do not place OAuth credentials in repository variables, source, workflow input,
logs, issues, or pull requests. The production API root is fixed in the tool and
cannot be overridden by repository or workflow input.
Expand Down
Loading