Merge pull request #40 from Flajt/dev #16
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
name: Deploy on PR | |
on: | |
push: | |
branches: | |
- main | |
- dev | |
jobs: | |
get_branch: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Branch check #Credits: https://www.codewrecks.com/post/github/choose-environment-from-branch/ | |
id: branch_check | |
run: | | |
echo "Running on branch ${{ github.ref }}" | |
if [ "${{ github.ref }}" = "refs/heads/main" ]; then | |
echo "::set-output name=env_name::prod" | |
elif [ "${{ github.ref }}" = "refs/heads/dev" ]; then | |
echo "::set-output name=env_name::dev" | |
fi | |
- name: Choosen Env | |
run: echo ${{ steps.branch_check.outputs.env_name }} | |
outputs: | |
env_name: ${{ steps.branch_check.outputs.env_name }} | |
build: | |
needs: [get_branch] | |
environment: | |
name: ${{ needs.get_branch.outputs.env_name }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
- name: Setup Go 1.20 | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.20' | |
cache-dependency-path: | | |
helper/go.sum | |
scw_secret_wrapper/go.sum | |
sign/go.sum | |
cronjob/go.sum | |
has_new_key/go.sum | |
get_new_key/go.sum | |
- name: Install all dependencies | |
run: cd ${{github.workspace}}/scw_secret_wrapper && go get . && cd ${{github.workspace}}/helper && go get . && cd ${{github.workspace}}/sign && go get . && cd ${{github.workspace}}/cronjob && go get . && cd ${{github.workspace}}/has_new_key && go get . && cd ${{github.workspace}}/get_new_key && go get . && cd ${{github.workspace}}/originstamp && go get . && cd ${{github.workspace}}/webhook && go get . && cd ${{github.workspace}}/verify_hash && go get . | |
- name: Run go mod vendor | |
run: cd ${{github.workspace}}/get_new_key && go mod vendor && cd ${{github.workspace}}/has_new_key && go mod vendor && cd ${{github.workspace}}/sign && go mod vendor && cd ${{github.workspace}}/cronjob && go mod vendor && cd ${{github.workspace}}/webhook && go mod vendor && cd ${{github.workspace}}/verify_hash && go mod vendor | |
- name: Convert secrets to env vars | |
uses: Firenza/secrets-to-env@v1.2.0 | |
with: | |
secrets: ${{ toJSON(secrets) }} | |
- name: Setup npm | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18' | |
- name: Install serverless | |
run: npm install -g serverless | |
- name: Install serverless plugin | |
run: serverless plugin install --name serverless-scaleway-functions | |
- name: Deploy functins | |
run: serverless deploy |