forked from deso-protocol/frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add script to trigger stage deploy from tags (#5)
- Loading branch information
Showing
1 changed file
with
52 additions
and
1 deletion.
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 |
---|---|---|
|
@@ -112,7 +112,7 @@ jobs: | |
trigger-deploy-dev: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
if: startsWith(github.ref, 'refs/tags/v') | ||
if: startsWith(github.ref, 'refs/tags/v') && !endsWith(github.ref, '_stage') | ||
steps: | ||
# Including the PERSONAL_ACCESS_TOKEN_CORE in the checkout. Without this the | ||
# following stefanzweifel/git-auto-commit-action will not trigger a | ||
|
@@ -149,3 +149,54 @@ jobs: | |
with: | ||
commit_message: "Automated Change | Deploy to dev | tags: ${{ steps.tag_id.outputs.tag }}" | ||
file_pattern: terraform-environments/* | ||
|
||
## Deploy to stage | ||
## Will only run on a tag release: v*_stage | ||
## Will update the stage's TF file's docker tag with the tag and commit it back into the 'main' branch | ||
## This will trigger a TF run to apply the changes | ||
trigger-deploy-stage: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
if: startsWith(github.ref, 'refs/tags/v') && endsWith(github.ref, '_stage') | ||
steps: | ||
# Including the PERSONAL_ACCESS_TOKEN_CORE in the checkout. Without this the | ||
# following stefanzweifel/git-auto-commit-action will not trigger a | ||
# new github action for deployment | ||
# doc: https://github.com/stefanzweifel/git-auto-commit-action#commits-made-by-this-action-do-not-trigger-new-workflow-runs | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
token: ${{ secrets.PERSONAL_ACCESS_TOKEN_CORE }} | ||
ref: 'main' | ||
|
||
- name: Extract tag var | ||
id: tag_id | ||
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/} | ||
|
||
- name: Remove _stage | ||
id: get-tag | ||
run: | | ||
tag_val=$(echo ${{steps.tag_id.outputs.tag}} | cut -d_ -f1) | ||
echo "::set-output name=tag_val::$tag_val" | ||
# Update the docker tags in the TF/helm deployment | ||
- name: Update stage image tag | ||
uses: jacobtomlinson/[email protected] | ||
with: | ||
find: "docker_tag = \".*\"" | ||
replace: "docker_tag = \"${{ steps.get-tag.outputs.tag_val }}\"" | ||
include: "terraform-environments/aws/stage/helm/70-gem-frontend/main.tf" | ||
|
||
- name: Check output | ||
run: | | ||
echo "ref: ${{ github.ref }}" | ||
echo "head_ref: ${{ github.head_ref }}" | ||
echo "base_ref: ${{ github.base_ref }}" | ||
echo ${{ steps.get-tag.outputs.tag_val }} | ||
cat terraform-environments/aws/stage/helm/70-gem-frontend/main.tf | ||
- name: Update dev deploy docker tags file | ||
uses: stefanzweifel/git-auto-commit-action@v4 | ||
with: | ||
commit_message: "Automated Change | Deploy to stage | tags: ${{ steps.get-tag.outputs.tag_val }}" | ||
file_pattern: terraform-environments/* |