fixing staging API url #125
This file contains hidden or 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: CI | |
| on: | |
| push: | |
| branches: [ master, dev ] | |
| pull_request: | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| # Skip CI build if this is a tag push (handled by release workflow) | |
| if: startsWith(github.ref, 'refs/tags/') == false | |
| env: | |
| GO111MODULE: on | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v2 | |
| - name: Set up Go | |
| uses: actions/setup-go@v2 | |
| with: | |
| go-version: '1.22.x' | |
| - name: Install Dependencies | |
| run: make GOBIN=$HOME/gopath/bin deps | |
| - name: Run Tests | |
| run: make GOBIN=$HOME/gopath/bin test | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.13' | |
| - name: Create Python Virtual Environment | |
| run: python -m venv .pyvenv | |
| - name: Run API Unit Tests | |
| run: make api-test | |
| - name: Run Coverage Tests | |
| env: | |
| COVERALLS_TOKEN: ${{ secrets.COVERALLS_TOKEN }} | |
| run: | | |
| $HOME/gopath/bin/goveralls -v -service=github | |
| - name: Build Project | |
| if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev' | |
| run: make GOBIN=$HOME/gopath/bin build | |
| - name: Build Docker Image | |
| if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev' | |
| run: docker build -t clintsharp/gogen . | |
| # Deployment steps run on both master and dev branches | |
| - name: Configure AWS Credentials | |
| if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev' | |
| uses: aws-actions/configure-aws-credentials@v1 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws-region: us-east-1 | |
| - name: Deploy Build Artifacts to S3 | |
| if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev' | |
| run: | | |
| if [ "${{ github.ref }}" = "refs/heads/master" ]; then | |
| aws s3 sync build s3://gogen-artifacts-prod --delete | |
| else | |
| aws s3 sync build s3://gogen-artifacts-staging --delete | |
| fi | |
| - name: Run Docker Push Script | |
| if: github.ref == 'refs/heads/master' | |
| env: | |
| DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} | |
| DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | |
| run: bash docker-push.sh | |
| - name: Setup Node.js | |
| if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev' | |
| uses: actions/setup-node@v2 | |
| with: | |
| node-version: '18' | |
| - name: Deploy UI | |
| if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev' | |
| run: | | |
| chmod +x ui/deploy_ui.sh | |
| if [ "${{ github.ref }}" = "refs/heads/master" ]; then | |
| ui/deploy_ui.sh | |
| else | |
| ui/deploy_ui.sh -e staging | |
| fi | |
| deploy-lambdas: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| # Skip if this is a tag push (handled by release workflow) | |
| if: (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev') && startsWith(github.ref, 'refs/tags/') == false | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v2 | |
| - name: Set up Python | |
| uses: actions/setup-python@v2 | |
| with: | |
| python-version: '3.13' | |
| - name: Install AWS SAM CLI | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install aws-sam-cli boto3 botocore awscli | |
| - name: Configure AWS Credentials | |
| uses: aws-actions/configure-aws-credentials@v1 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws-region: us-east-1 | |
| - name: Deploy Lambda Functions | |
| env: | |
| # Set ROLE_ARN based on the branch | |
| ROLE_ARN: ${{ github.ref == 'refs/heads/master' && secrets.PROD_LAMBDA_ROLE_ARN || secrets.STAGING_LAMBDA_ROLE_ARN }} | |
| # Set GitHub OAuth credentials based on the branch | |
| GITHUB_OAUTH_CLIENT_ID: ${{ github.ref == 'refs/heads/master' && secrets.PROD_GITHUB_OAUTH_CLIENT_ID || secrets.STAGING_GITHUB_OAUTH_CLIENT_ID }} | |
| GITHUB_OAUTH_CLIENT_SECRET: ${{ github.ref == 'refs/heads/master' && secrets.PROD_GITHUB_OAUTH_CLIENT_SECRET || secrets.STAGING_GITHUB_OAUTH_CLIENT_SECRET }} | |
| run: | | |
| cd gogen-api | |
| if [ "${{ github.ref }}" = "refs/heads/master" ]; then | |
| # Prod deployment | |
| bash deploy_lambdas.sh | |
| else | |
| # Staging deployment | |
| bash deploy_lambdas.sh -e staging | |
| fi |