Skip to content

Commit

Permalink
Fix deploy-packages triggered from tag-internal (#1230)
Browse files Browse the repository at this point in the history
* WIP

* Update name

* Make changes optional

* Update version to 0.3.2-internal-testing-workflow-changes-1806 (#1232)

* Revert "Update version to 0.3.2-internal-testing-workflow-changes-1806 (#1232)"

This reverts commit f921318.

* Make revert explicit

* Update deployed packages for 67dd36f (#1234)

* Update version to 0.3.2-internal-testing-workflow-1113

* Revert version back to 0.3.2-dev

---------

Co-authored-by: Moose Jobs <[email protected]>
  • Loading branch information
pierd and moose-jobs authored Dec 23, 2023
1 parent 62e3a25 commit 79d4dc4
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 8 deletions.
33 changes: 28 additions & 5 deletions .github/workflows/deploy-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,17 @@
name: Deploy packages

on:
workflow_dispatch: {}
workflow_dispatch:
inputs:
base:
description: 'Base branch to merge update deployed packages to (no merging if not specified)'
required: false
default: ''
revert:
description: 'Revert version back to the specified version (you should only use this for merging to main)'
required: false
default: false
type: boolean

env:
CARGO_TERM_COLOR: always
Expand Down Expand Up @@ -48,16 +58,29 @@ jobs:
- name: Deploy all packages
run: cargo campfire-slim package deploy-all --token ${{ secrets.AMBIENT_CLOUD_DEPLOY_TOKEN }} --include-examples

- name: Commit and push changed files (for nightly builds)
# only commit and push if this is running in a nightly build tag
if: startsWith(github.ref, 'refs/tags/v') && contains(github.ref, '-nightly-')
- name: Commit and push changed files without revert
if: github.event.inputs.base && !github.event.inputs.revert
run: |
base_branch=main
base_branch=${{ github.event.inputs.base }}
branch=${base_branch}-deployed-${{ github.sha }}
git config --global user.name "${{ env.BOT_NAME }}"
git config --global user.email "${{ env.BOT_EMAIL }}"
git checkout -b ${branch}
git commit -a -m "Update deployed packages for ${{ github.sha }}" || true
git push --set-upstream origin ${branch}
pr_url=$(gh pr create --title "Update deployed packages for ${{ github.sha }}" --body "Deployed packages for ${{ github.sha }}" --base ${base_branch} --head ${branch})
gh pr merge --auto --squash --delete-branch ${pr_url}
- name: Commit and push changed files with version revert
if: github.event.inputs.base && github.event.inputs.revert
run: |
base_branch=${{ github.event.inputs.base }}
tag=${GITHUB_REF#refs/tags/}
branch=${tag}-deployed-${{ github.sha }}
git config --global user.name "${{ env.BOT_NAME }}"
git config --global user.email "${{ env.BOT_EMAIL }}"
git checkout -b ${branch}
git commit -a -m "Update deployed packages for ${{ github.sha }}" || true
# switch back to the main branch version
version_majminpat=$(echo ${tag} | sed -E -e 's/^v([0-9]+\.[0-9]+\.[0-9]+).*$/\1/')
Expand Down
33 changes: 31 additions & 2 deletions .github/workflows/release-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,17 @@
name: Release

on:
workflow_dispatch: {}
workflow_dispatch:
inputs:
packages_merge_base:
description: 'Base branch to merge update deployed packages to (no merging if not specified)'
required: false
default: 'main'
packages_merge_revert:
description: 'Revert version back to the specified version (you should only use this for merging to main)'
required: false
default: true
type: boolean
push:
tags: [v*]
branches:
Expand Down Expand Up @@ -162,6 +172,25 @@ jobs:
- name: Upload debug symbols
run: sentry-cli upload-dif -o dims -p native-client ${{ env.EXE_DIR }}/${{ matrix.exe_name }} ${{ env.EXE_DIR }}/${{ matrix.symbol_path }}

trigger-deploy-packages-jobs:
needs: meta
runs-on: ubuntu-22.04
steps:
- name: Trigger deploy packages job
uses: actions/github-script@v6
with:
script: |
github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'deploy-packages.yml',
ref: '${{ needs.meta.outputs.tag }}',
inputs: {
base: '${{ github.event.inputs.packages_merge_base || 'main' }}',
revert: ${{ github.event.inputs.packages_merge_revert == 'true' }},
},
})
trigger-build-jobs:
needs: meta
runs-on: ubuntu-22.04
Expand All @@ -170,7 +199,7 @@ jobs:
uses: actions/github-script@v6
with:
script: |
for (const workflow_id of ['deploy-server.yml', 'deploy-web.yml', 'deploy-packages.yml', 'deploy-docs.yml']) {
for (const workflow_id of ['deploy-server.yml', 'deploy-web.yml', 'deploy-docs.yml']) {
github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
Expand Down
17 changes: 16 additions & 1 deletion .github/workflows/tag-internal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,17 @@ jobs:
date_suffix=$(date +%Y-%m-%d)
echo "version_suffix=nightly-${date_suffix}" >> $GITHUB_ENV
- name: Extract base branch and revert flag
if: github.event_name == 'workflow_dispatch' && startsWith(github.ref, 'refs/heads/')
run: |
echo "base_branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
echo "revert=false" >> $GITHUB_ENV
- name: Extract base branch and revert flag
if: github.event_name == 'schedule'
run: |
echo "base_branch=main" >> $GITHUB_ENV
echo "revert=true" >> $GITHUB_ENV
- name: Update version and tag
id: tag
run: |
Expand All @@ -64,7 +75,7 @@ jobs:
git tag ${tag}
git push origin ${tag}
echo tag=${tag} >> $GITHUB_OUTPUT
- name: Trigger build jobs
- name: Trigger the release job
uses: actions/github-script@v6
with:
script: |
Expand All @@ -73,4 +84,8 @@ jobs:
repo: context.repo.repo,
workflow_id: 'release-version.yml',
ref: '${{ steps.tag.outputs.tag }}',
inputs: {
packages_merge_base: '${{ env.base_branch }}',
packages_merge_revert: '${{ env.revert }}',
}
})

0 comments on commit 79d4dc4

Please sign in to comment.