I'm trying to set up a deployment using GitHub actions. Build the React app and use express to serve it.
name: EB Deploy
on:
push:
branches: [ main ]
jobs:
deploy:
runs-on: ubuntu-latest
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
steps:
- uses: actions/checkout#v2
- name: Set up Python 3.9
uses: actions/setup-python#v2
with:
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install awsebcli
- uses: actions/setup-node#v2
with:
node-version: '16'
- name: Deploy to Elastic Beanstalk
run: |
cd client
npm i
npm run build
mv dist ..
cd ..
eb deploy
app.use(express.static(path.join(__dirname, './dist')))
Everything works fine except eb doesn't deploy dist folder.
Even when I run eb labs download to download the deployed version I don't see dist folder in the zip file.
I ended up zipping the whole dir and eb deploy --staged it, for it to work.
I guess eb was ignoring the dist folder because it wasn't being tracked by git. I added these commands:
git config --global user.email "GH-DEPLOY#aws.null"
git config --global user.name "GH-DEPLOY"
git add dist
git commit -m 'add react app'
eb deploy --staged
Related
We have a monorepo that we are using Lerna to publish to a private package manager (nexus). When the action runs, it fails with same vague message:
info cli using local version of lerna
lerna notice cli v5.3.0
lerna info ci enabled
Error: Process completed with exit code 1.
This message occurs after github actions tries to run the lerna publish command.
I've tried dozens of variations of installing Lerna globally and locally as well as all sort of variations of flags on my lerna bootstrap and lerna publish commands. I am not sure what to try. Any insights would be appreciated. Below is my worklflow file.
Node: 16.15.1
Lerna: 5.3.0
release.yml
name: 'MyPackage Production Release'
on:
workflow_dispatch:
inputs:
version:
required: true
type: choice
description: Which version should be published?
options:
- patch
- minor
- major
tag:
required: true
type: choice
description: Which npm tag should this be published to?
options:
- latest
- next
- test
jobs:
build-my-package:
runs-on: [self-hosted, Linux, X64, enterprise]
steps:
- uses: actions/checkout#v3
with:
fetch-depth: 0 #indicates all history for all branches and tags.
- uses: actions/setup-node#v3
with:
node-version: 16.15.1
registry-url: 'https://registry.npmjs.org'
- name: Configure Identity
run: |
git config user.name github-actions
git config user.email github-actions#github.com
shell: bash
- name: strict SSL
run: |
npm config set cafile my-file.pem
npm config set strict-ssl false
npm config set https-proxy http://proxy.our.proxysite.net:80/
npm config set proxy http://proxy.our.proxysite.net:80/
npm config set NODE_TLS_REJECT_UNAUTHORIZED=0
npm config set registry https://registry.npmjs.org/
- name: Install Dependencies
run: |
npm ci --no-package-lock --legacy-peer-deps
lerna bootstrap --ignore-scripts -- --legacy-peer-deps
shell: bash
- name: Prepare Nexus Token
run: |
npm config set registry https://nexus.our.site.net/repository/my-package-repo/
npm config set email myemail#myemail.net
npm config set strictSSL false
npm config set alwaysAuth true
echo //nexus.our.site.net/repository/my-package-repo/:_auth=${{ secrets.NEXUS_BASE64_AUTH }} > .npmrc
npm config set _auth ${{ secrets.NEXUS_BASE64_AUTH }}
shell: bash
- name: Release
run: |
HUSKY_SKIP_HOOKS=1 lerna publish $(echo "${{ github.event.inputs.version }}") --yes --force-publish='*' --dist-tag $(echo "${{ github.event.inputs.tag }}") --conventional-commits --create-release github
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
GHE_API_URL: ${{ secrets.GHE_API_URL }}
GHE_VERSION: ${{ secrets.GHE_VERSION }}
shell: bash
How do I specify whether to zappa deploy or zappa update my application in Github actions with some sort of if statement
My Workflow Actions as per below
name: Dev Deploy
on:
push:
branches:
- mybranch
jobs:
dev-deploy:
name: Deploy to Dev
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v1
- name: Set up Python 3.9.10
uses: actions/setup-python#v1
with:
python-version: 3.9.10
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest
pip install python-Levenshtein
pip install virtualenv
- name: Install zappa
run: pip install zappa
- name: Install Serverless
run: npm install -g serverless
- name: Configure Serverless for zappa Services
run: serverless config credentials --provider aws --key myAWSKey --secret myAWSSecret
- name: Deploy to Dev
run: |
python -m virtualenv envsp
source envsp/bin/activate
zappa deploy dev
If application already deployed once, I get the error
Error: This application is already deployed - did you mean to call update?
In which case I would want to run zappa update dev
I am currently working on setting up a workflow for my Github Pages site. I have successfully created html files from Python and now only need to publish. I am using this Github Action for doing that. However, my builds fail with the error message:
github-pages 222 | Error: No such file or directory # rb_check_realpath_internal - /github/workspace/bin/python3
I have the file /bin/python3 in my repository and it should additionally not be used for that build shouldnt it?
Why is it getting used and how do I fix it?
Note: I am not limited to this specific action. If there is another one that works better I would be happy to use it!
This is my worker file right now:
name: Jekyll site CI
on:
push:
branches: [ gh-pages ]
pull_request:
branches: [ gh-pages ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout#v2.4.0
- name: install python
uses: actions/setup-python#v2
with:
python-version: "3.9.2"
- name: install python packages
run: |
python -m pip install --upgrade pip
pip install jinja2
- name: run python script
run: python app.py
- name: Deploy to GitHub Pages
if: success()
uses: crazy-max/ghaction-github-pages#v2.5.0
with:
build_dir: ./
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
I have been trying to automate the deployment of firebase cloud functions using the Github actions CI/CD workflows.
The functions are developed using NodeJs, Express, and Typescript. And all environment variables are saved in a .env file that is not tracked on github (for obvious reasons)
The main.yaml file (in .github/workflows/)
name: CI/CD
on:
push:
branches: [ deploy ]
pull_request:
branches: [ deploy ]
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- name: create env file
run: |
cd functions
touch .env
echo "${{ secrets.ENV_VARS }}" >> .env
- name: Install npm packages
run: |
cd functions
npm install
- name: Deploy to Firebase
uses: w9jds/firebase-action#master
with:
args: deploy
env:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
The workflow first creates a .env file where it writes the env variables (saved in github secrets)
then installs the dependencies,
and finally deploy the cloud functions
The steps are executed without any issues, up to the deployment part where I got this error
Error: Service account object must contain a string "project_id" property.
at FirebaseAppError.FirebaseError [as constructor] (/github/workspace/functions/node_modules/firebase-admin/lib/utils/error.js:44:28)
at FirebaseAppError.PrefixedFirebaseError [as constructor] (/github/workspace/functions/node_modules/firebase-admin/lib/utils/error.js:90:28)
at new FirebaseAppError (/github/workspace/functions/node_modules/firebase-admin/lib/utils/error.js:125:28)
at new ServiceAccount (/github/workspace/functions/node_modules/firebase-admin/lib/credential/credential-internal.js:134:19)
at new ServiceAccountCredential (/github/workspace/functions/node_modules/firebase-admin/lib/credential/credential-internal.js:68:15)
at Object.exports.cert (/github/workspace/functions/node_modules/firebase-admin/lib/credential/credential.js:34:54)
at Object.<anonymous> (/github/workspace/functions/lib/config/firebase.js:10:34)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
Thank you in advance
I solved this problem. The answer was very simple: instead of following the different tutorials that use "w9jds/firebase-action#master" for the deployment, I simply used firebase deploy :)
The new main.yaml
name: CI/CD
on:
push:
branches: [ deploy]
pull_request:
branches: [ deploy]
workflow_dispatch:
jobs:
main:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
# Environment variables
- name: create env file
run: |
cd functions
touch .env
echo "${{ secrets.ENV_VARS }}" >> .env
# Install npm packages and firebase
- name: Install npm packages
run: |
cd functions
npm install
npm audit fix
npm install firebase-tools
# Run tests
- name: Run tests
run: |
cd functions
npm run test
# Deploying the functions to firebase
- name: Deploy to Firebase
run: |
cd functions
npm run deploy
env:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
I have an action on master branch which on push/merge builds a package, uploads it to PyPI then checks out to develop branch, bumps version in develop branch and pushes to the origin of develop branch. Develop branch has an action that listens to push/merge and does a snapshot release.
When I push to develop the develop action works perfectly and does a snapshot release, but when master branch pushes, push is successful but the action does not get triggered. What am I missing?
Both actions are added below.
name: Build and Upload Package to PyPI | Master Branch
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v1
- name: Set up Python
uses: actions/setup-python#v1
with:
python-version: '3.5'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
pip install GitPython
pip install bumpversion
- name: Strip 'snapshot' from version
run: sed -i 's/-snapshot//g' setup.py
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
TWINE_REPOSITORY_URL: https://pypi.domain.com
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
- name: Bump Verison and Push to develop
run: |
git stash
git config --local user.email "name#email.com"
git config --local user.name "username"
git checkout develop
python bump_version.py
cat .bumpversion.cfg
git remote set-url --push origin https://username:$GITHUB_TOKEN#github.com/repo/path
git push origin develop
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
name: Build and Upload Package to PyPI | Develop Branch
on:
push:
branches:
- develop
jobs:
bumpTag_build_and_publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v1
- name: Set up Python
uses: actions/setup-python#v1
with:
python-version: '3.5'
- name: Install dependencies for setup
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
TWINE_REPOSITORY_URL: https://pypi.domain.co,
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
Provided secrets.GITHUB_TOKEN is intentionally not allowed to trigger workflows. As seen in documention:
(...) if an action pushes code using the repository's GITHUB_TOKEN, a new workflow will not run even when the repository contains a workflow configured to run when push events occur.
If you need your automagic push to be "visible" by workflows, you need to create Personal Access Token, add it to repo secrets, and use that instead of GITHUB_TOKEN.
Note that GitHub assumes that you know what you're doing, if you use non-stock token - which means preventing possible infinite loop is on you. While it's not a case in your scenario for now (develop branch does not push anything), it's worth to remember in case one of workflows will change some day.