-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 7a15d13
Showing
5 changed files
with
148 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
name: Pull latest changes from quickstart repository | ||
on: | ||
workflow_dispatch: | ||
schedule: | ||
- cron: '0 13 * * 1' | ||
jobs: | ||
pull-request-source-repo: | ||
name: Create pull request | ||
runs-on: ubuntu-latest | ||
env: | ||
WORKING_BRANCH: auto | ||
steps: | ||
- name: Get GitHub App token | ||
uses: actions/create-github-app-token@v1 | ||
id: app-token | ||
with: | ||
app-id: ${{ secrets.PORTAL_QUICKSTART_SYNCHRONIZER_APP_ID }} | ||
private-key: ${{ secrets.PORTAL_QUICKSTART_SYNCHRONIZER_PRIVATE_KEY }} | ||
- name: Checkout source repository | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: azure-samples/cosmos-db-nosql-dotnet-quickstart | ||
ref: main | ||
path: source | ||
- name: Checkout target repository | ||
uses: actions/checkout@v4 | ||
with: | ||
token: ${{ steps.app-token.outputs.token }} | ||
ref: ${{ github.head_ref }} | ||
path: target | ||
- name: Get GitHub App User ID | ||
id: get-user-id | ||
env: | ||
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} | ||
run: echo "user-id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT" | ||
- name: Configure git | ||
working-directory: target | ||
run: | | ||
git config --global user.name '${{ steps.app-token.outputs.app-slug }}[bot]' | ||
git config --global user.email '${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com>' | ||
- name: Generate date variables | ||
run: | | ||
echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV | ||
echo "WORKING_BRANCH=auto-$(date +'%Y%m%d%H%M%S')" >> $GITHUB_ENV | ||
- name: Create working branch | ||
working-directory: target | ||
run: git checkout -b $WORKING_BRANCH | ||
- name: Copy source to target | ||
run: cp -ra source/src/. target/ | ||
- name: Change text content | ||
working-directory: target | ||
run: | | ||
content=$(cat .github/workflows/replace.cs) | ||
awk -v content="$content" ' | ||
BEGIN { in_block = 0 } | ||
/^\s*\/\/ <create_client>/ { in_block = 1; print content; next } | ||
/^\s*\/\/ <\/create_client>/ { in_block = 0; next } | ||
!in_block { print } | ||
' web/Program.cs > web/Program.tmp.cs && mv web/Program.tmp.cs web/Program.cs | ||
- name: Add changes to git | ||
working-directory: target | ||
run: | | ||
git add . | ||
- name: Check if files are changed | ||
id: check-files | ||
working-directory: target | ||
run: | | ||
echo "status=$(git diff --shortstat --staged)" >> $GITHUB_OUTPUT | ||
- name: Commit and push changes | ||
if: ${{ steps.check-files.outputs.status != '' }} | ||
working-directory: target | ||
run: | | ||
git commit -m "Automatically generated commit" | ||
git push --set-upstream origin $WORKING_BRANCH | ||
- name: Create auto-merge pull request | ||
if: ${{ steps.check-files.outputs.status != '' }} | ||
working-directory: target | ||
env: | ||
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} | ||
run: | | ||
url=$(gh pr create --title "[AUTO] $CURRENT_DATE | Merge latest from source repo" --body "${{ steps.check-files.outputs.status}}" --base main --head $WORKING_BRANCH) | ||
gh pr merge --auto --merge $url | ||
echo $url |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: Create release for default branch | ||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
jobs: | ||
create-release: | ||
name: Create release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
- name: Get GitHub App token | ||
uses: actions/create-github-app-token@v1 | ||
id: app-token | ||
with: | ||
app-id: ${{ secrets.PORTAL_QUICKSTART_SYNCHRONIZER_APP_ID }} | ||
private-key: ${{ secrets.PORTAL_QUICKSTART_SYNCHRONIZER_PRIVATE_KEY }} | ||
- name: Generate output | ||
id: generate | ||
run: | | ||
echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT | ||
echo "tag=release-$(date +'%Y%m%d%H%M%S')" >> $GITHUB_OUTPUT | ||
- name: Create compressed folder | ||
run: | | ||
mkdir out | ||
git archive --format=zip --output out/project.zip main | ||
- name: Push release | ||
env: | ||
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} | ||
run: | | ||
gh release create ${{ steps.generate.outputs.tag }} \ | ||
'out/project.zip#Project folder' \ | ||
--title 'Release ${{ steps.generate.outputs.date }}' | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
CosmosClient client = new( | ||
connectionString: "<azure-cosmos-db-nosql-connection-string>" | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: Validate project | ||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
branches: | ||
- main | ||
jobs: | ||
validate-dotnet: | ||
name: Validate .NET build and format | ||
runs-on: ubuntu-latest | ||
container: mcr.microsoft.com/dotnet/sdk:8.0 | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
- name: Check .NET version | ||
run: dotnet --version | ||
- name: Build .NET solution | ||
run: dotnet build | ||
- name: Check .NET code format | ||
run: dotnet format --verify-no-changes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Quickstart - Azure Cosmos DB for NoSQL - .NET | ||
|
||
| Task | Link | | ||
| --- | --- | | ||
| Downloaded latest source code | <https://github.com/azurecosmosdb/quickstart-nosql-dotnet/releases/latest/download/project.zip> | | ||
| Open in GitHub Codespaces | <https://codespaces.new/AzureCosmosDB/quickstart-nosql-dotnet?template=true&quickstart=1> | |