-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate to GitHub Actions and Azure App Service (#312)
* Update local build instructions and README * rename main site configuration files to be main-site*.json * provide a local Docker image to run DocFX as a convenience * Bump DocFX versions to 2.59.2 Co-authored-by: Chris Cheetham <[email protected]> Co-authored-by: bart-vmware <[email protected]>
- Loading branch information
1 parent
25e6b37
commit acc12e9
Showing
31 changed files
with
368 additions
and
347 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,55 @@ | ||
name: build-api-docs | ||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
paths: | ||
- .github/workflows/build-APIdocs-layer.yml | ||
- Dockerfile-metadata | ||
|
||
push: | ||
branches: | ||
- main | ||
paths: | ||
- .github/workflows/build-APIdocs-layer.yml | ||
- Dockerfile-metadata | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
env: | ||
tagv2: 2.5.5 | ||
tagv3: 3.2.6 | ||
|
||
permissions: | ||
contents: 'read' | ||
|
||
jobs: | ||
build-push: | ||
name: Build and push API docs layer | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set Steeltoe versions to use | ||
run: |- | ||
echo '2:'${{ env.tagv2 }} > metadata.conf | ||
echo '3:'${{ env.tagv3 }} >> metadata.conf | ||
echo "STEELTOE_VERSIONS=${{ env.tagv2 }}-${{ env.tagv3 }}" >> $GITHUB_ENV | ||
shell: bash | ||
|
||
- name: Login to container registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: "${{ vars.DOCKER_REGISTRY }}" | ||
username: "${{ secrets.DOCKER_USERNAME }}" | ||
password: "${{ secrets.DOCKER_PASSWORD }}" | ||
|
||
- name: Build image | ||
run: docker build . --file "Dockerfile-metadata" -t ${{ vars.DOCKER_REGISTRY }}/documentation-metadata:${{ env.STEELTOE_VERSIONS }} | ||
|
||
- name: Push image | ||
if: ${{ github.event_name != 'pull_request' }} | ||
run: docker push ${{ vars.DOCKER_REGISTRY }}/documentation-metadata:${{ env.STEELTOE_VERSIONS }} |
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,91 @@ | ||
name: build-website | ||
on: | ||
workflow_run: | ||
workflows: [build-api-docs] | ||
types: [completed] | ||
pull_request: | ||
branches: | ||
- main | ||
paths: | ||
- "*" | ||
- "!README.md" | ||
- "!docfx/" | ||
- "!build-metadata.sh" | ||
- "!metadata.conf" | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- "*" | ||
- "!README.md" | ||
- "!docfx/" | ||
- "!build-metadata.sh" | ||
- "!Dockerfile-metadata" | ||
- "!metadata.conf" | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
permissions: | ||
contents: 'read' | ||
pull-requests: 'write' | ||
|
||
env: | ||
IMAGE_TAG: ${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.number) || github.run_id }} | ||
|
||
jobs: | ||
build-push-deploy: | ||
name: Build and push documentation image | ||
environment: | ||
name: ${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.number) || vars.STAGING_SLOT_NAME }} | ||
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} | ||
env: | ||
SLOT_NAME: ${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.number) || vars.STAGING_SLOT_NAME }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Login to Azure | ||
uses: azure/login@v1 | ||
with: | ||
creds: ${{ secrets.AZURE_CREDENTIALS }} | ||
|
||
- name: Login to container registry | ||
uses: azure/docker-login@v1 | ||
with: | ||
login-server: "${{ vars.DOCKER_REGISTRY }}" | ||
username: "${{ secrets.DOCKER_USERNAME }}" | ||
password: "${{ secrets.DOCKER_PASSWORD }}" | ||
|
||
- name: Build image | ||
run: docker build . --file "Dockerfile" -t ${{ vars.DOCKER_REGISTRY }}/documentation:${{ env.IMAGE_TAG }} | ||
|
||
- name: Push image | ||
run: docker push ${{ vars.DOCKER_REGISTRY }}/documentation:${{ env.IMAGE_TAG }} | ||
|
||
- name: If PR, create a new staging slot | ||
if: ${{ github.event_name == 'pull_request' }} | ||
run: az webapp deployment slot create --resource-group ${{ vars.AZURE_RESOURCE_GROUP }} --name ${{ vars.AZURE_WEBAPP_NAME}} --slot ${{ env.SLOT_NAME }} | ||
|
||
- name: Deploy to staging slot | ||
uses: azure/webapps-deploy@v3 | ||
id: deploy-to-webapp | ||
with: | ||
app-name: ${{ vars.AZURE_WEBAPP_NAME }} | ||
images: ${{ vars.DOCKER_REGISTRY }}/documentation:${{ env.IMAGE_TAG }} | ||
slot-name: ${{ env.SLOT_NAME }} | ||
|
||
- name: If PR, comment with the preview link | ||
if: ${{ github.event_name == 'pull_request' }} | ||
uses: mshick/add-pr-comment@v2 | ||
with: | ||
message: | | ||
## Preview link: https://${{ vars.AZURE_WEBAPP_NAME }}-${{ env.SLOT_NAME }}.azurewebsites.net | ||
- Your changes have been deployed to the preview site. The preview site will update as you add more commits to this branch. | ||
- The preview link is shareable, but will be deleted when the pull request is merged or closed. | ||
> *This is an automated message.* | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
|
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,43 @@ | ||
name: build-base-layer | ||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- .github/workflows/build-base-layer.yml | ||
- docfx/ | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
env: | ||
docfxVersion: 2.59.2 | ||
|
||
permissions: | ||
contents: 'read' | ||
|
||
jobs: | ||
build-push: | ||
name: Build and push base layer | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set DocFX version to use | ||
run: echo v${{ env.docfxVersion }} > docfx/version | ||
shell: bash | ||
|
||
- name: Login to container registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: "${{ vars.DOCKER_REGISTRY }}" | ||
username: "${{ secrets.DOCKER_USERNAME }}" | ||
password: "${{ secrets.DOCKER_PASSWORD }}" | ||
|
||
- name: Build image | ||
run: docker build docfx --file "docfx/Dockerfile" -t ${{ vars.DOCKER_REGISTRY }}/docfx:${{ env.docfxVersion }} | ||
|
||
- name: Push image | ||
run: docker push ${{ vars.DOCKER_REGISTRY }}/docfx:${{ env.docfxVersion }} |
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,32 @@ | ||
name: Delete a preview environment | ||
|
||
on: | ||
pull_request: | ||
types: [closed] | ||
|
||
env: | ||
SLOT_NAME: pr-${{ github.event.number }} | ||
|
||
jobs: | ||
delete-slot: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Log into Azure CLI with service principal | ||
uses: azure/login@v1 | ||
with: | ||
creds: ${{ secrets.AZURE_CREDENTIALS }} | ||
|
||
- name: Delete slot on staging site | ||
run: az webapp deployment slot delete --resource-group ${{ vars.AZURE_RESOURCE_GROUP }} --name ${{ vars.AZURE_WEBAPP_NAME}} --slot ${{ env.SLOT_NAME }} | ||
|
||
delete-deployment: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Delete Deployment Environment | ||
uses: strumwolf/delete-deployment-environment@v2 | ||
with: | ||
environment: "pr-${{ github.event.number }}" | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
onlyRemoveDeployments: true |
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,22 @@ | ||
name: Swap staging slot contents into production | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
promote-to-production: | ||
name: Promote to production | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: 'Production' | ||
url: 'https://${{ vars.AZURE_WEBAPP_NAME }}.azurewebsites.net/' | ||
|
||
steps: | ||
- name: Log into Azure CLI with service principal | ||
uses: azure/login@v1 | ||
with: | ||
creds: ${{ secrets.AZURE_CREDENTIALS }} | ||
|
||
- name: Swap slots | ||
run: az webapp deployment slot swap -s ${{ vars.STAGING_SLOT_NAME }} -n ${{ vars.AZURE_WEBAPP_NAME }} -g ${{ vars.AZURE_RESOURCE_GROUP }} | ||
|
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 |
---|---|---|
@@ -1,8 +1,8 @@ | ||
/api/browser/**/*.manifest | ||
/api/browser/**/*.yml | ||
/obj/ | ||
/build/ | ||
/sources/ | ||
/_site/ | ||
/tools/ | ||
/.vscode/ | ||
/.vs/ | ||
|
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 |
---|---|---|
@@ -1,11 +1,11 @@ | ||
FROM steeltoe.azurecr.io/documentation-metadata:3.2.0-2.5.5-6 AS build | ||
FROM steeltoe.azurecr.io/documentation-metadata:2.5.5-3.2.6 AS build | ||
WORKDIR /docs | ||
COPY . . | ||
RUN docfx build -o build --globalMetadataFiles host.json | ||
RUN docfx build -o /built-docs --globalMetadataFiles main-site.json | ||
|
||
FROM nginx:1.19 | ||
RUN rm -rf /usr/share/nginx/html | ||
COPY --from=build /docs/build/_site /usr/share/nginx/html | ||
COPY --from=build /built-docs/_site /usr/share/nginx/html | ||
COPY nginx.conf /etc/nginx/conf.d/default.conf | ||
COPY docker/ / | ||
COPY *.env /etc/documentation-site/ |
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
FROM steeltoe.azurecr.io/docfx:2.57.2-11 | ||
FROM steeltoe.azurecr.io/docfx:2.59.2 | ||
WORKDIR /docs | ||
COPY . . | ||
RUN ["chmod", "+x", "./build-metadata.sh"] | ||
RUN ./build-metadata.sh |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.