[{"data":1,"prerenderedAt":416},["ShallowReactive",2],{"page:\u002Fdocs\u002F5.x\u002Fintegrations\u002Fgithub-actions":3},{"id":4,"title":5,"body":6,"description":400,"extension":401,"frontmatter":402,"heading":5,"meta":408,"navigation":409,"order":404,"path":410,"seo":411,"sitemap":412,"source":413,"stem":414,"__hash__":415},"docs\u002Fdocs\u002F5.x\u002Fintegrations\u002Fgithub-actions.md","Publish Kubb snapshots with GitHub Actions",{"type":7,"value":8,"toc":392},"minimark",[9,18,23,76],[10,11,12,13,17],"p",{},"Publish an installable Kubb Studio snapshot from GitHub Actions so reviewers can compare generated files against the base branch and previous runs. Store ",[14,15,16],"code",{},"KUBB_TOKEN"," as an Actions repository secret.",[19,20,22],"h2",{"id":21},"prerequisites","Prerequisites",[24,25,26,40,54],"ul",{},[27,28,29,30,33,34,39],"li",{},"A repository with a working ",[14,31,32],{},"kubb.config.ts"," on Kubb 5.6.2 or later. Follow ",[35,36,38],"a",{"href":37},"\u002Fdocs\u002F5.x\u002Fhow-to\u002Finstallation","Installation"," if you have not set up Kubb.",[27,41,42,43,47,48,50,51,53],{},"A ",[35,44,46],{"href":45},"\u002Fdocs\u002F5.x\u002Fintegrations\u002Fstudio","Kubb Studio"," organization and an organization CI API key, stored as ",[14,49,16],{}," in a secret only trusted pipelines can read. Snapshot installation uses a separate registry key. Create both in Studio under Settings › Developers › Tokens, with type CI for ",[14,52,16],{}," and type Registry for installs.",[27,55,56,59,60,63,64,67,68,71,72,75],{},[14,57,58],{},"tsdown"," in the development dependencies, next to ",[14,61,62],{},"kubb",", so ",[14,65,66],{},"npm ci"," installs it. A snapshot builds its ",[14,69,70],{},"dist"," files with it, and Kubb does not install it by default: ",[14,73,74],{},"npm i -D tsdown",".",[77,78,80,84,87,331,341,344,364,368,387],"steps",{"level":79},"2",[19,81,83],{"id":82},"configure-the-workflow","Configure the workflow",[10,85,86],{},"Add this workflow:",[88,89,94],"pre",{"language":90,"filename":91,"code":92,"class":93},"yaml",".github\u002Fworkflows\u002Fkubb.yml","name: Kubb snapshot\n\non:\n  pull_request:\n    # `closed` deletes the pull request's Studio agent. GitHub leaves it out by default.\n    types: [opened, synchronize, reopened, closed]\n  # A snapshot of main is what pull requests compare with.\n  push:\n    branches: [main]\n\npermissions:\n  contents: write\n  pull-requests: write\n\njobs:\n  snapshot:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions\u002Fcheckout@v5\n      - uses: kubb-labs\u002Faction@v0\n        with:\n          token: ${{ secrets.KUBB_TOKEN }}","highlights",[14,95,97,114,115,114,117,114,125,114,135,114,144,114,178,114,185,114,194,114,210,114,212,114,219,114,231,114,242,114,244,114,251,114,260,114,272,114,280,114,293,114,308,114,318],{"class":96},"language-yaml",[98,99,102,106,110],"span",{"class":100,"style":101},"line","display: inline",[98,103,105],{"style":104},"color:#005cc5;--hls-dark:#79b8ff","name",[98,107,109],{"style":108},"color:#d73a49;--hls-dark:#f97583",": ",[98,111,113],{"style":112},"color:#032f62;--hls-dark:#9ecbff","Kubb snapshot","\n",[98,116],{"class":100,"style":101},[98,118,119,122],{"class":100,"style":101},[98,120,121],{"style":104},"on",[98,123,124],{"style":108},":",[98,126,127,130,133],{"class":100,"style":101},[98,128,129],{"style":108},"  ",[98,131,132],{"style":104},"pull_request",[98,134,124],{"style":108},[98,136,137,140],{"class":100,"style":101},[98,138,139],{"style":108},"    ",[98,141,143],{"style":142},"color:#6a737d;--hls-dark:#6a737d","# `closed` deletes the pull request's Studio agent. GitHub leaves it out by default.",[98,145,146,148,151,153,156,159,162,165,167,170,172,175],{"class":100,"style":101},[98,147,139],{"style":142},[98,149,150],{"style":104},"types",[98,152,109],{"style":108},[98,154,155],{"style":104},"[",[98,157,158],{"style":112},"opened",[98,160,161],{"style":108},", ",[98,163,164],{"style":112},"synchronize",[98,166,161],{"style":108},[98,168,169],{"style":112},"reopened",[98,171,161],{"style":108},[98,173,174],{"style":112},"closed",[98,176,177],{"style":104},"]",[98,179,180,182],{"class":100,"style":101},[98,181,129],{"style":104},[98,183,184],{"style":142},"# A snapshot of main is what pull requests compare with.",[98,186,187,189,192],{"class":100,"style":101},[98,188,129],{"style":142},[98,190,191],{"style":104},"push",[98,193,124],{"style":108},[98,195,196,198,201,203,205,208],{"class":100,"style":101},[98,197,139],{"style":108},[98,199,200],{"style":104},"branches",[98,202,109],{"style":108},[98,204,155],{"style":104},[98,206,207],{"style":112},"main",[98,209,177],{"style":104},[98,211],{"class":100,"style":101},[98,213,214,217],{"class":100,"style":101},[98,215,216],{"style":104},"permissions",[98,218,124],{"style":108},[98,220,221,223,226,228],{"class":100,"style":101},[98,222,129],{"style":108},[98,224,225],{"style":104},"contents",[98,227,109],{"style":108},[98,229,230],{"style":112},"write",[98,232,233,235,238,240],{"class":100,"style":101},[98,234,129],{"style":112},[98,236,237],{"style":104},"pull-requests",[98,239,109],{"style":108},[98,241,230],{"style":112},[98,243],{"class":100,"style":101},[98,245,246,249],{"class":100,"style":101},[98,247,248],{"style":104},"jobs",[98,250,124],{"style":108},[98,252,253,255,258],{"class":100,"style":101},[98,254,129],{"style":108},[98,256,257],{"style":104},"snapshot",[98,259,124],{"style":108},[98,261,262,264,267,269],{"class":100,"style":101},[98,263,139],{"style":108},[98,265,266],{"style":104},"runs-on",[98,268,109],{"style":108},[98,270,271],{"style":112},"ubuntu-latest",[98,273,274,276,278],{"class":100,"style":101},[98,275,139],{"style":112},[98,277,77],{"style":104},[98,279,124],{"style":108},[98,281,282,285,288,290],{"class":100,"style":101},[98,283,284],{"style":108},"      - ",[98,286,287],{"style":104},"uses",[98,289,109],{"style":108},[98,291,292],{"style":112},"actions\u002Fcheckout@v5",[98,294,295,298,301,303,305],{"class":100,"style":101},[98,296,297],{"style":112},"      ",[98,299,300],{"style":108},"- ",[98,302,287],{"style":104},[98,304,109],{"style":108},[98,306,307],{"style":112},"kubb-labs\u002Faction@v0",[98,309,310,313,316],{"class":100,"style":101},[98,311,312],{"style":112},"        ",[98,314,315],{"style":104},"with",[98,317,124],{"style":108},[98,319,320,323,326,328],{"class":100,"style":101},[98,321,322],{"style":108},"          ",[98,324,325],{"style":104},"token",[98,327,109],{"style":108},[98,329,330],{"style":112},"${{ secrets.KUBB_TOKEN }}",[10,332,333,336,337,340],{},[14,334,335],{},"pull-requests: write"," allows snapshot comments. ",[14,338,339],{},"contents: write"," lets the action open an initialization pull request when the repository has no Kubb config. For that pull request, turn on Allow GitHub Actions to create and approve pull requests under Settings > Actions > General.",[10,342,343],{},"Review the pull request comment for generated changes against the base branch and the previous run.",[10,345,346,347,350,351,358,359,363],{},"To pass the tarball URL to another step, give the action an ",[14,348,349],{},"id: snapshot",", then read ",[14,352,357],{"$":353,":v-pre":356},{"html":354,"block":355},1,0,"true","${{ steps.snapshot.outputs.tarball-url }}",". See the ",[35,360,362],{"href":361},"\u002Fdocs\u002F5.x\u002Freference\u002Fgithub-actions","action reference"," for all inputs, outputs, and runtime behavior.",[19,365,367],{"id":366},"review-and-install-the-result","Review and install the result",[10,369,370,371,374,375,378,379,382,383,75],{},"Studio has no diff view for snapshots. The GitHub Action lists the changed generated files in its pull request comment, and ",[14,372,373],{},"kubb studio snapshot --json"," reports them in ",[14,376,377],{},"changes"," and ",[14,380,381],{},"branchChanges"," with any provider. To consume the generated package, follow ",[35,384,386],{"href":385},"\u002Fdocs\u002F5.x\u002Fintegrations\u002Fci#install-the-snapshot","Install the snapshot",[388,389,391],"blockquote",{"as":390},"note","Snapshots expire after seven days. Schedule a default-branch run if it can go a week without a push.",{"title":393,"searchDepth":394,"depth":394,"links":395},"",5,[396,398,399],{"id":21,"depth":397,"text":22},2,{"id":82,"depth":397,"text":83},{"id":366,"depth":397,"text":367},"Add the kubb-labs\u002Faction workflow to publish a Kubb Studio snapshot on each pull request and compare generated files with the base branch and the previous run.","md",{"layout":403,"title":5,"description":400,"order":404,"navigation":405},"doc",3,{"title":406,"icon":407},"GitHub Actions","i-simple-icons-githubactions",{"layout":403},{"title":406,"icon":407},"\u002Fdocs\u002F5.x\u002Fintegrations\u002Fgithub-actions",{"title":5,"description":400},{"loc":410},"kubb-labs\u002Fkubb\u002Fdocs\u002F5.x\u002Fintegrations\u002Fgithub-actions.md","docs\u002F5.x\u002Fintegrations\u002Fgithub-actions","pDt_OC9wp0D1yr8vkyAp5F-4W8LButlne8gJasoMhOA",1792931641147]