Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: Add workflow to push to avd.arista.com on every devel commit #3849

Closed
wants to merge 2 commits into from

Conversation

gmuloc
Copy link
Contributor

@gmuloc gmuloc commented Apr 12, 2024

Change Summary

WIP

Related Issue(s)

Fixes #

Component(s) name

arista.avd.<role-name>

Proposed changes

How to test

Checklist

User Checklist

  • N/A

Repository Checklist

  • My code has been rebased from devel before I start
  • I have read the CONTRIBUTING document.
  • My change requires a change to the documentation and documentation have been updated accordingly.
  • I have updated molecule CI testing accordingly. (check the box if not applicable)

@github-actions github-actions bot added the type: code quality CI and development toolset label Apr 12, 2024
@JulioPDX
Copy link
Contributor

I think this gets us there. We do have to provide some type of PAT

---
# This is deploying the latest commits on devel to aristanetworks/avd-docs main branch
name: Deploy devel documentation to aristanetworks/avd-docs main
on:
  push:
    branches:
      - devel
  workflow_dispatch:

jobs:
  'devel_doc':
    name: 'Update Public devel documentation'
    runs-on: ubuntu-latest
    if: github.repository == 'aristanetworks/avd'
    steps:
      - name: Checkout AVD
        uses: actions/checkout@v4
        with:
          fetch-depth: 0
          path: ./avd

      - name: Checkout docs repo
        uses: actions/checkout@v4
        with:
          repository: aristanetworks/avd-docs
          token: ${{ secrets.DOCS_ACCESS_TOKEN }}
          fetch-depth: 0
          path: ./docs

      - name: 'Setup Python 3 on runner'
        uses: actions/setup-python@v5
        with:
          python-version: '3.x'

      - name: Setup Git config
        run: |
          git config --global user.name 'github-actions[bot]'
          git config --global user.email 'github-actions[bot]@users.noreply.github.com'

      - name: 'Build mkdocs content and deploy to aristanetworks/avd-docs on main'
        run: |
            cd ./docs
            pip install -r ../avd/ansible_collections/arista/avd/docs/requirements.txt
            mike deploy --push -b main devel --config-file ../avd/mkdocs.yml

@gmuloc
Copy link
Contributor Author

gmuloc commented Apr 16, 2024

Thanks @JulioPDX - feel free to add commits to this PR
Have you tried this workflow somewhere? I am concerned that the snippet path would still be broken

@JulioPDX
Copy link
Contributor

Thanks @JulioPDX - feel free to add commits to this PR Have you tried this workflow somewhere? I am concerned that the snippet path would still be broken

I believe you are right about snippets, let me reevaluate this solution

@JulioPDX
Copy link
Contributor

@gmuloc yeah I tried it on some private repos, I think this gets us all we need with devel, since that version already exists, we can use standard git to update the directory. I'll add you to the private repos if you'd like to test.

---
# This is deploying the latest commits on devel to aristanetworks/avd-docs main branch
name: Deploy devel documentation to aristanetworks/avd-docs main

on:
  push:
    branches:
      - devel
  workflow_dispatch:

concurrency:
  group: ${{ github.workflow }}-${{ github.head_ref }}
  cancel-in-progress: true

jobs:
  'devel_doc':
    name: 'Update Public devel documentation'
    runs-on: ubuntu-latest
    if: github.repository == 'aristanetworks/avd'
    steps:
      - name: Checkout AVD
        uses: actions/checkout@v4
        with:
          fetch-depth: 0
          path: devel

      - name: Checkout docs repo
        uses: actions/checkout@v4
        with:
          repository: aristanetworks/avd-docs
          token: ${{ secrets.REPO_ACCESS_TOKEN }}
          fetch-depth: 0
          path: docs

      - name: 'Setup Python 3 on runner'
        uses: actions/setup-python@v5
        with:
          python-version: '3.x'

      - name: Setup Git config
        run: |
          git config --global user.name 'github-actions[bot]'
          git config --global user.email 'github-actions[bot]@users.noreply.github.com'

      - name: 'Build mkdocs content and deploy to aristanetworks/avd-docs on main'
        run: |
            cd ./devel
            pip install .[doc]
            mkdocs build -d ../docs/devel
            cd ../docs
            git add .
            git commit -m "updating devel with $GITHUB_SHA"
            git push
          

@gmuloc
Copy link
Contributor Author

gmuloc commented Apr 29, 2024

Closing as we agreed it would be implemented in avd-docs repo.
cc @JulioPDX

@gmuloc gmuloc closed this Apr 29, 2024
@JulioPDX JulioPDX reopened this Apr 29, 2024
@JulioPDX
Copy link
Contributor

@gmuloc @carlbuchmann Need your opinion on something, I got this to work using workflow dispatch, but this still requires some type of secret to be set since the docs repository is private. We would still need a dispatch workflow on the avd repo. Example below from my test repositories.

On AVD:

devel-doc.yml

---
name: Deploy devel documentation
on:
  push:
    branches:
      - devel
  workflow_dispatch:

jobs:
  'devel_doc':
    name: 'Update Public devel documentation'
    runs-on: ubuntu-latest
    if: github.repository == 'JulioPDX/production-test'
    steps:
      - name: Run dispatch
        run: |
          curl -L \
            -X POST \
            -H "Accept: application/vnd.github+json" \
            -H "Authorization: Bearer ${{ secrets.REPO_ACCESS_TOKEN }}" \
            -H "X-GitHub-Api-Version: 2022-11-28" \
            https://api.github.com/repos/JulioPDX/push-test/actions/workflows/test.yml/dispatches \
            -d '{"ref":"main"}'

On docs repo

test.yml

---
name: Deploy devel documentation
on:
  workflow_dispatch:

jobs:
  'devel_doc':
    name: 'Update Public devel documentation'
    runs-on: ubuntu-latest
    steps:
      - name: Checkout docs repo
        uses: actions/checkout@v4
        with:
          path: docs

      - name: Checkout AVD
        uses: actions/checkout@v4
        with:
          repository: JulioPDX/production-test
          path: avd

      - name: 'Setup Python 3 on runner'
        uses: actions/setup-python@v5
        with:
          python-version: '3.x'

      - name: Setup Git config
        run: |
          git config --global user.name 'github-actions[bot]'
          git config --global user.email 'github-actions[bot]@users.noreply.github.com'
      - name: 'Build mkdocs content and deploy'
        run: |
            cd ./avd
            pip install -r requirements.txt
            mkdocs build -d ../docs/devel
            cd ../docs
            git add .
            git commit -m "updating devel with $GITHUB_SHA"
            git push

@gmuloc
Copy link
Contributor Author

gmuloc commented Apr 29, 2024

@JulioPDX can we do without token the other way around )(avd-docs subscribing to push events on devel in main avd repo?)

@JulioPDX
Copy link
Contributor

@JulioPDX can we do without token the other way around )(avd-docs subscribing to push events on devel in main avd repo?)

I can take a look at this option. Thank you

@JulioPDX
Copy link
Contributor

JulioPDX commented May 3, 2024

Closing as this has been implemented in the docs repo. Thank you

@JulioPDX JulioPDX closed this May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: code quality CI and development toolset
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants