Create temporal token before deployment #16
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Desplegar pagina" | |
on: | |
pull_request: | |
branches: | |
- "*" | |
push: | |
branches: | |
- "develop" | |
- "production" | |
workflow_dispatch: | |
env: | |
DEPLOY: >- | |
${{ | |
github.event_name != 'pull_request' | |
&& | |
(github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/production') | |
}} | |
OUTPUT: _html | |
TZ: America/Bogota | |
jobs: | |
build: | |
name: Construir sitio web lektor | |
runs-on: ubuntu-latest | |
steps: | |
- name: Generate access token | |
if: always() | |
id: generate_access_token | |
uses: actions/create-github-app-token@v1 | |
with: | |
app-id: ${{ secrets.PYTHON_CO_APP_ID }} | |
private-key: ${{ secrets.PYTHON_CO_APP_KEY }} | |
owner: ${{ github.repository_owner }} | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
- name: Install Lektor | |
run: | | |
pipx ensurepath | |
pipx install lektor | |
- name: Build Lektor site | |
run: lektor build -O '${{ env.OUTPUT }}' | |
- name: Deploy Lektor site | |
if: env.DEPLOY == 'true' | |
env: | |
GITHUB_TOKEN: ${{ steps.generate_access_token.outputs.token }} | |
run: | | |
git config --global user.name "pythonco-auth[bot]" | |
git config --global user.email "pythonco-auth[bot]@users.noreply.github.com" | |
git remote set-url origin https://x-access-token:${{ steps.generate_access_token.outputs.token }}@github.com/ColombiaPython/sitio-web-desarrollo.git | |
# Ensure that the 'gh-pages' branch exists | |
if ! git rev-parse --verify origin/gh-pages; then | |
git checkout --orphan gh-pages | |
git reset --hard | |
echo "Initializing gh-pages branch" > README.md | |
git add README.md | |
git commit -m "Initialize gh-pages branch" | |
git push origin gh-pages | |
fi | |
lektor deploy -O '${{ env.OUTPUT }}' |