This guide will walk you through setting up GitHub Actions to automatically deploy your code to Miget whenever you push to the main branch. The process is fully automated using a GitHub Actions workflow defined in a YAML file.

Prerequisites

Before you begin, ensure you have the following:
  1. Miget Repository: You should have a Miget repository set up where you want to deploy your code. You can find the Miget repository for your App under Deploy tab at app.miget.com.
  2. GitHub Repository: The source code that you want to deploy should be hosted on GitHub.
  3. Miget Token: A Miget access token that can be used to authenticate and push changes to your Miget repository. This token should be stored as a secret in your GitHub repository.

Get Miget Token

Navigate to Settings tab, and click Git Tokens Next, you will see an Information box with a deploy commands.
Miget deploy commands panel showing git instructions
Click See the token button and grab your token.
  • The default username for the HTTPS-based git repo is your Miget name.
  • The password is the token.
  • If you revoke the default token associated with your Miget name, you won’t be able to deploy.
  • If you add a new Git token, the token name is the Username for Git, and the token itself is the Password.

Add Miget Token to Github

Navigate to your GitHub repository and go the Settings Page. Under Secrets and variables please click on Actions
GitHub repository settings showing Secrets and variables menu
Click New repository secret and add your Miget token with the name MIGET_TOKEN_KEY. Save the secret. This will securely store the Miget token, which can be referenced in your workflow file.
GitHub new repository secret modal configuring MIGET_TOKEN_KEY

Create the GitHub Actions Workflow File

First, you’ll need to create a YAML file in your GitHub repository to define the workflow for deployment. You can place this file under .github/workflows/deploy-to-miget.yaml in your repository.
name: Deploy to Miget
on:
  push:
    branches:
      - main

jobs:
  deploy:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v2
        with:
          fetch-depth: 0

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

      - name: Add Miget remote
        run: |
          git remote add miget https://<your-miget-name>:$MIGET_TOKEN_KEY@git.eu-east-1.miget.io/<your-miget-name>/<your-app-name>
        env:
          MIGET_TOKEN_KEY: ${{ secrets.MIGET_TOKEN_KEY }}

      - name: Push to Miget
        run: git push miget

      - name: Cleanup
        run: git remote remove miget
Remember to replace code in brackets with your values!

Deploying to Miget

Once the workflow file is in place, any time you push code to the main branch, GitHub Actions will automatically trigger the deployment process to Miget. After pushing to the main branch, you can monitor the deployment process by going to the Actions tab in your GitHub repository. Here, you can view the status of your workflow and see logs for each step.