Helper to sync repository from GitHub to WVS

This repository provides a tool to help you set up a one-way mirror from your GitHub Repository to a new repository on WVS so you can continue using GitHub and still take advantage of the automation features of WVS.

over-view]

Setup Overview

To get the GitHub bridge to sync, it will require a total of six variables.

  • 2 variables will be set up in your Git Repo
  • 4 Variables will be set up in WVS

Please remember that you will not be sharing or storing passwords, and everything you store on WVS is encrypted in our database. Personal Access tokens are used in place of a password to allow you to set limitations on what can be accessed and allow you to revoke at any time.

Setup

In WVS

  1. Fork this repo to the group or namespace you want to store your mirrored repository by clicking the Fork button on the project homepage.

fork-git

  1. Next, grab information for two new variables. The table below gives you a breakdown of how to find the information.
Variable Location Screenshot
WVS_PROJECT_ID In WVS Under Project Settings -> General, Look for Project ID. prID
WVS_TRIGGER_TOKEN In WVS Under Project Settings -> CI/CD -> Pipeline Triggers
  • Enter a name under Description
  • Click Add Trigger
  • Copy the Token
token

In GitHub

  1. Go to your GitHub account and select the project you plan to bridge so we can get started on adding the two new variables from step 2 to your GitHub project:
  • Under Settings -> Secrets and Variables -> Actions
    • Click New Repository Secret
    • Add WVS_PROJECT_ID and WVS_TRIGGER_TOKEN with the value from Step 2

action-secrets

  1. Generate GitHub Personal Access Token

You will need this token for step 5 as the GITHUB_PAT portion of the GITHUB_SYNC_SOURCE variable.

Variable Location Screenshot
GITHUB_PAT In GitHub click the Profile Icon -> Settings -> Developer Settings -> Personal Access Tokens -> Tokens(classic)
  • Click Generate new token > select Generate new token(classic) (You might be asked to reauthenticate to GitHub)
  • Note: WVS Sync
  • Expiration: Recommend you set it for 1 year (max), also recommend to add to your calendar so you don't forget to generate a new one.
  • Under Select Scopes: Scopes define the access for personal tokens select repo
  • Click Generate Token at the bottom of the page.
  • Copy and save your token.
github-pat gh-class-permission

*Optional You can use the Fine-grained tokens if it's available for you but since that is still in Beta, we are using the the classic token.

In WVS

  1. Add four new Variables to your WVS project:
  • In WVS Under Project Settings -> CI/CD -> Variables
    • Please Note all variables set in WVS are stored encrypted within our database.
Variable Location Screenshot
GITHUB_SYNC_SOURCE https://<GITHUB_USERNAME>:<GITHUB_PAT>@github.com/<GITHUB_PROJECT_PATH>/<GITHUB_PROJECT_NAME>.git (This is just project HTTP clone URL, with username and GitHub PAT) Example: https://githubUser:ghp_1ABCDEF234GH5IJK67L8M9NOPQRST12345@github.com/wvsUsr/myTestProject.git
WVS_PAT Create a Personal Access Token under your WVS user profile
  • WVS profile Icon -> Access Tokens
  • Enter a Token Name, this can be anything GitHub Sync is a good recommendation.
  • Select api, api_read, read_repository, write_repository
  • Click Create personal Access token
github-sync Copy the token shown under Your new personal access token. IMPORTANT: Save this token. This is the only time it will be displayed.
WVS_PAT_USER WVS username associated with WVS_PAT above
WVS_SYNC_TARGET (ie janthony/wvs-sync-test) (Note this project should not exists yet)

In GitHub

  1. GitHub Action
  • Add a GitHub action to your project to trigger the sync.

This is just a text-based yml file in your Github repository. ex: .github/workflows/wvs-sync.yml:

You can grab the working example here or copy the example below.

name: WVSTrigger

# Controls when the workflow will run
on:
  # Triggers the workflow on push or pull request events but only for the branches specified
  push:
  pull_request:
    branches: [ "main", "wvs-sync" ]

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # This workflow contains a single job called "build"
  trigger:
    runs-on: ubuntu-latest

    steps:
      - name: Trigger WVS Pipeline
        env:
          WVS_TRIGGER_TOKEN: ${{ secrets.WVS_TRIGGER_TOKEN }}
          WVS_PROJECT_ID: ${{ secrets.WVS_PROJECT_ID }}
        run: |
          echo "Triggering pipeline at https://wvs.io/api/v4/projects/${WVS_PROJECT_ID}/trigger/pipeline"
          curl -D - -XPOST --fail -F token=${WVS_TRIGGER_TOKEN} -F ref=main https://wvs.io/api/v4/projects/${WVS_PROJECT_ID}/trigger/pipeline

Menu