Helper to sync repository from GitHub to WVS

The Github sync repository contains a sync-helper tool that helps 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.

Setup Overview


  1. Create and configure the sync-helper tool project on WVS.
    • 4 variables will be set up in WVS.
  2. Configure your existing project on GitHub.
    • 2 variables will be set up in GitHub.

Although you will not be storing any passwords during this setup, it is still important that the tokens you store are kept secure.
Please follow the instructions carefully to ensure all your secrets remain secure.

Setup

In WVS

  1. Fork the Github Sync repository that can be found here 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.
    • For security, select the Mask checkbox when adding your WVS_PAT and GITHUB_SYNC_SOURCE variable so the value of the variables do not show up in the logs for each flow.

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-save-pat
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

Confirm Sync

If you don’t see any data in WVS, you can check in your GitHub account. Click on the Actions tab from the top to see an action for the sync on the list.

If your action fails, double-check your settings and rerun the job.

How it works

over-view

Troubleshooting

Still having problems setting up? For additional support, please reach out to us on our Discord.

Was this helpful?

We would love to hear your feedback, Submit a ticket in our Issue Tracker.


Report a problem with this page.