-
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.
Adding hot-upgrade CI used by manual deploy
- Loading branch information
1 parent
860d8c6
commit 96081a4
Showing
3 changed files
with
95 additions
and
6 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
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,85 @@ | ||
name: Deploy a hot-upgrade package/version to AWS | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
tag: | ||
required: true | ||
type: string | ||
|
||
env: | ||
MIX_ENV: prod | ||
|
||
jobs: | ||
build: | ||
name: Building a release and publishing it at AWS | ||
runs-on: ubuntu-20.04 | ||
permissions: | ||
contents: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Setup BEAM | ||
uses: erlef/setup-beam@v1 | ||
with: | ||
version-file: .tool-versions | ||
version-type: strict | ||
|
||
- name: Retrieve the deployed current.json | ||
uses: prewk/s3-cp-action@v2 | ||
with: | ||
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
aws_region: "sa-east-1" | ||
source: "s3://calori-${{ secrets.CLOUD_ENV_NAME }}-distribution/versions/calori/${{ secrets.CLOUD_ENV_NAME }}/current.json" | ||
dest: "./s3-current.json" | ||
|
||
- name: Compile the current deployed version | ||
run: | | ||
VERSION=$(cat s3-current.json | jq '.version' | tr -d '"') | ||
HASH=$(cat s3-current.json | jq '.hash' | tr -d '"') | ||
echo ${VERSION} ${HASH} | ||
git checkout ${HASH} | ||
sed -i "s/.*version:.*/ version: \"${VERSION}\",/" mix.exs | ||
mix deps.get | ||
mix compile | ||
mix assets.deploy | ||
mix release | ||
echo "Return to the current branch head: ${GITHUB_SHA}" | ||
git checkout ${GITHUB_SHA} | ||
- name: Update project mix version | ||
run: | | ||
sed -i "s/.*version:.*/ version: \"${{ inputs.tag }}\",/" mix.exs | ||
- name: Create Release file version | ||
run: | | ||
echo "{\"version\":\"${{ inputs.tag }}\",\"hash\":\"${GITHUB_SHA}\"}" | jq > current.json | ||
- name: Install Elixir dependencies | ||
run: mix do deps.get, compile | ||
|
||
- name: Assets Deploy | ||
run: mix assets.deploy | ||
|
||
- name: Generate a Release | ||
run: mix release | ||
|
||
- name: Copy a release file to the s3 distribution folder | ||
uses: prewk/s3-cp-action@v2 | ||
with: | ||
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
aws_region: "sa-east-1" | ||
source: "_build/prod/calori-${{ inputs.tag }}.tar.gz" | ||
dest: "s3://calori-${{ secrets.CLOUD_ENV_NAME }}-distribution/dist/calori/calori-${{ inputs.tag }}.tar.gz" | ||
|
||
- name: Copy a version file to the s3 version folder | ||
uses: prewk/s3-cp-action@v2 | ||
with: | ||
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
aws_region: "sa-east-1" | ||
source: "current.json" | ||
dest: "s3://calori-${{ secrets.CLOUD_ENV_NAME }}-distribution/versions/calori/${{ secrets.CLOUD_ENV_NAME }}/current.json" |
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