Build GitPages Using GitHub Actions - build

.github - workflows - github-pages.yml and dry-run.yml
name: Deploy to GitHub Pages
on:
pull_request:
branches:
- master
jobs:
github-pages:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- uses: helaili/jekyll-action#2.0.5
build_only: true
Footer
name: Deploy to GitHub Pages
on:
push:
branches:
- master
jobs:
github-pages:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- uses: helaili/jekyll-action#v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
Git Actions result
Auto-regeneration: disabled. Use --watch to enable.
Jekyll build done
Error: Cannot publish on branch master
master(Default branch) gh-pages(Active branches) I am using two branches.
What is the workaround for the bug?

Maybe you should change
on:
push:
branches:
- master
to another branch

Related

Bitbucket pipelines with different build variables

I have a simple Vue.js project that utilizes Vite to build the distribution. I am utilizing dotenv to target specific environments for my deployment via different .env files such as .env and .env.dev where .env may contain
VITE_APP_TITLE=My Site (local)
and .env.dev might contain
VITE_APP_TITLE=My Site (dev)
Running vite build and vite build --mode dev generates the correct distribution with the appropriate substitutions, however, I cannot seem to get a similar behavior from Bitbucket pipelines.
My build pipeline currently looks like this
image: node:14
pipelines:
branches:
develop:
- step:
name: Build and Test
caches:
- node
script:
- npm install
# - npm test
- step:
name: Run build
script:
- npm install
- npm run build:dev
artifacts:
- dist/**
caches:
- node
- step:
name: Deploy to dev
deployment: dev
script:
- echo "Deploying to dev environment"
- pipe: atlassian/aws-s3-deploy:0.3.8
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
S3_BUCKET: $AWS_BUCKET
LOCAL_PATH: 'dist'
ACL: 'public-read'
- step:
name: Invalidate Cloudfront Cache
script:
- pipe: atlassian/aws-cloudfront-invalidate:0.6.0
variables:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
AWS_DEFAULT_REGION: $AWS_DEFAULT_REGION
DISTRIBUTION_ID: $AWS_DISTRIBUTION_ID
PATHS: "/index.html"
I am utilizing the repository "Deployments" setting to add variables for the deployment stage but there does not appear to be a way for me to access these for the build stage as the deployment: setting can only be used during one stage of the pipeline. Has anyone figured out a way to account for different build environment variables during the build stage of the pipeline that could point me in the right direction?
If you want full control, you would need to go with custom steps and variables. But this doesn't allow for easy automation.
So for automation it is about question on when the deployment end would change? If it's based on the branch/tag, then you would just do a separate pipeline with the settings hardcoded into it per different deployment. If it's all going thru the same way, then you are more limited on how to control it.

How to implement ./cloud_sql_proxy in GitHub Actions?

jobs:
job1:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- name: Download Cloud SQL Auth Proxy
run: |
wget https://dl.google.com/cloudsql/cloud_sql_proxy.linux.amd64 -O cloud_sql_proxy
chmod +x cloud_sql_proxy
job2:
needs: job1
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- run: ./cloud_sql_proxy \
-instances=...
I got this error:
./cloud_sql_proxy: No such file or directory
I wanna separate job1 and job2.
How can I use ./cloud_sql_proxy command in job2?
Github jobs do not share files or data unless you take action to do so. One of the reasons is they can run in parallel on different systems/containers/computers.
There are several options. The easiest is to create a step in job2 that does the same download as the step in job1. Other options include workflow artifacts (upload and download) and cache.

How to run automated tests in Github actions for Kotlin?

Language: Kotlin,
my build.yml file is:
name: Build
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- uses: actions/setup-java#v2
with:
java-version: '11'
distribution: 'adopt'
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action#e6e38bacfdf1a337459f332974bb2327a31aaf4b
- name: Run the Gradle package task
uses: gradle/gradle-build-action#937999e9cc2425eddc7fd62d1053baf041147db7
- name: Grant Permissions to gradlew
run: chmod +x gradlew
- name: Test
run: ./gradlew test
It sees the test file correctly. But there is a test that has to fail. Yet it successfully passes in GitHub actions. How can I run tests correctly in GitHub actions?

Expo Web Build in Vercel - Command "npx expo-cli build:web" exited with 1

I want to build and deploy my expo app in vercel. I know that I can build it locally (expo build:web), cd into the build folder and run vercel, but I would like it to be done automatically with source control integration.
So I have connected my github repository, npm install seems to be working ok. The problem is with the build command. I tried expo build:web but this failed because the expo cli is not installed in vercel, so I tried npx expo-cli build:web and got the folloowing output: Command "npx expo-cli build:web" exited with 1.
Error: Could not find MIME for Buffer <null>
at /vercel/.npm/_npx/727/lib/node_modules/expo-cli/node_modules/xdl/src/Webpack.ts:294:23
at finalCallback (/vercel/.npm/_npx/727/lib/node_modules/expo-cli/node_modules/webpack/lib/Compiler.js:257:39)
Does anyone know how I can run expo build:web in vercel? Many thanks
From my perspective, I think you need to use something like GitHub actions for this task.
I wrote a post on How I automated the releases with the expo-cli and I think we need to follow the same logic.
// .github/workflows/staging.yml
name: Expo Publish on Staging
on:
push:
branches:
- develop
jobs:
publish:
name: Install and publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v1
- uses: actions/setup-node#v1
with:
node-version: 12.x
- uses: expo/expo-github-action#v5
with:
expo-version: 3.x
expo-username: ${{ secrets.EXPO_CLI_USERNAME }}
expo-password: ${{ secrets.EXPO_CLI_PASSWORD }}
expo-cache: true
- run: yarn
- run: expo build:web <------- not sure if it works tho
- run: <------- here we need a way to upload to vercel
I am in the same situation as you —trying to automate the react-native-web to vercel release.
I had the same issue, but found a solution. expo build:web creates a production ready static bundle in the web-build/ directory, which Vercel can deploy. Thus, to deploy the Expo Web-app to Vercel, one can first have a GHA-step that runs expo build:web and then deploy the bundle it produces to Vercel.
Note that one either has to specify the path to the web-build directory as the root-directory in Vercel (which is done in the code below) or has to set the working-directory to the web-build-path in the Vercel step in the code.
Full Github Actions code for job:
deploy-web-staging:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout#v2
- name: Setup .npmrc and use node 14.15.1
uses: actions/setup-node#v1
with:
node-version: 14.15.1
- name: Expo Web
uses: expo/expo-github-action#v5
with:
expo-username: ${{ secrets.EXPO_CLI_USERNAME }}
expo-password: ${{ secrets.EXPO_CLI_PASSWORD }}
expo-cache: true
- name: Install dependencies
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: yarn
- name: Build Expo Web
working-directory: ./packages/app
run: expo build:web
- name: Vercel Deploy
uses: amondnet/vercel-action#v20.0.0
with:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
github-token: ${{ secrets.GITHUB_TOKEN }}
vercel-org-id: VERCEL_ORG_ID
vercel-project-id: VERCEL_PROJECT_ID
scope: TEAM

How to use github action to deploy a serverless mono repo with multiple packages.json?

I'm trying to deploy micro services that are part of a mono repo, for this I'm using github actions but I'm having an issue related to the plugins in the package.json files. This is the structure of my project:
--repo
---package.json
---resources
----package.json
---services
----Service A
-----package.json
----Service B
-----package.json
First I'm trying to deploy the resources folder that basically creates S3 buckets, cognito user pool, etc... and I have added the plugin called "serverless-cognito-add-custom-attributes" as part of this project, this plugin only exists on the package.json that is inside the "resources" folder.
I'm getting this error when trying to deploy from github actions :
Serverless plugin "serverless-cognito-add-custom-attributes" not found. Make sure it's installed and listed in the "plugins" section of your serverless config file.
this is the .yml file I'm using on github actions:
name: Deploy Resources to Dev
on:
push:
branches:
- dev
tags:
- RC-*
paths:
- './resources'
jobs:
InstallActions:
name: deploy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- name: Download Node
uses: actions/setup-node#v1
with:
node-version: "12.x"
- name: Install NPM Global Packages
run: |
npm install --global
npm install "./resources" --global
- name: Serverless Deploy
uses: serverless/github-action#master
with:
args: deploy --stage dev --config "./resources/serverless.yml"
env:
AWS_ACCESS_KEY_ID: ${{secrets.AWS_ACCESS_KEY_DEV}}
AWS_SECRET_ACCESS_KEY: ${{secrets.AWS_SECRET_ACCESS_KEY_DEV}}
When the above .yml file run I can see this on the console:
+ ----#1.0.0
added 1 package in 2.935s
+ resources#1.0.0
added 3 packages from 3 contributors in 0.654s
for some reason it seems that
uses: serverless/github-action#master
is unable to find the packages when installed from a sub folder, but doing all manually seems to work fine:
name: Deploy Resources to Dev
on:
push:
branches:
- dev
tags:
- RC-*
paths:
- './resources'
jobs:
Deploy:
name: deploy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- name: Download Node
uses: actions/setup-node#v1
with:
node-version: "12.x"
- name: Install Serverless Framework
run: npm install -g serverless
- name: Serverless Authentication
run: sls config credentials --provider aws --key ${{secrets.AWS_ACCESS_KEY_DEV}} --secret ${{secrets.AWS_SECRET_ACCESS_KEY_DEV}}
- name: Install NPM dependencies
run: |
npm install
npm install "./resources"
- name: Deploy to AWS
run: serverless deploy -v -s dev
working-directory: "./resources"
I had this problem for around 17 hours and then decided to go all manual instead of using the package serverless/github-action#master