Yii2 deploy using GitHub actions - github

I was using the following configuration to deploy Yii2 applications with GitHub actions:
name: Build and Deploy - DEV
on:
push:
branches:
- development
jobs:
build:
name: Build and Deploy
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout#master
- name: Setup Enviroment
uses: shivammathur/setup-php#v2
with:
php-version: '7.2'
- name: Install Packages
run: composer install --no-dev --optimize-autoloader
- name: Deploy to Server
uses: yiier/yii2-base-deploy#master
with:
user: github
host: ${{ host }}
path: ${{ path }}
owner: github
env:
DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }}
- name: Apply migration
run: php yii migrate --interactive=0
It worked quite well, but now is giving this error:
Current runner version: '2.285.1'
Operating System
Virtual Environment
Virtual Environment Provisioner
GITHUB_TOKEN Permissions
Secret source: Actions
Prepare workflow directory
Prepare all required actions
Getting action download info
Error: Unable to resolve action `yiier/yii2-base-deploy#master`, repository not found
Appears that yiier/yii2-base-deploy#master no longer existis.
Anyone knows a replacer?
Thanks!

Thanks to SiZE comment i remember I had fork the original repo.

Related

Workflow `GITHUB_TOKEN` not authorised to download packages from GitHub registry

Following this documentation, I'm using the default GITHUB_TOKEN secret to download & publish packages from another repository of mine (same scope) on GitHub registry, from a workflow. Yarn is configured to use the environment variable GITHUB_TOKEN. When using the default GITHUB_TOKEN secret, I get a 403 (Forbidden) error when downloading the package.
When using a PAT (a secret named TOKEN that I define manually with write:packages right), it works fine, when not using any token, I get a different error. Therefore, I assume the token is well transmitted and there is a right issue.
What am I missing?
Thank you.
Here is my repository settings (Actions > General) :
Allow all actions and reusable workflows: Any action or reusable workflow can be used, regardless of who authored it or where it is defined.
Read & write permissions: Workflows have read and write permissions in the repository for all scopes.
Here is a test workflow (link here):
name: Test Token
on:
workflow_dispatch:
jobs:
# Fail
github:
name: Test GitHub Token
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout#v3
- name: Setup Node
uses: actions/setup-node#v3
with:
node-version: 18
- name: Install dependencies
run: yarn install
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Success
pat:
name: Test PAT
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout#v3
- name: Setup Node
uses: actions/setup-node#v3
with:
node-version: 18
- name: Install dependencies
run: yarn install
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}

Github Actions - Invalid workflow file

I am trying to build CI/CD pipelines using GitHub Actions but unfortunately, I am stuck with an error with the yaml file.
Here is my Yaml file is:
---
name: Build and push python code to gcp with github actions
on:
push:
branches:
- main
jobs:
build_push_grc:
name: Build and push to gcr
runs_on: unbuntu-latest
env:
IMAGE_NAME: learning_cicd
PROJECT_ID: personal-370316
steps:
- name: Checkoutstep
uses: actions/checkout#v2
- uses: google-github-actions/setup-gcloud#master
with:
service_account_key: ${{ secrets.SERVICE_ACCOUNT_KEY}}
project_id: ${{ env.PROJECT_ID }}
export_default_credentials: true
- name: Build Docker Image
run: docker build -t $IMAGE_NAME:latest .
- name: Configure Docker Client
run: |-
gcloud auth configure-docker --quiet
- name: Push Docker Image to Container Registry (GCR)
env:
GIT_TAG: v0.1.0
run: |-
docker tag $IMAGE_NAME:latest gcr.io/$PROJECT_ID/$IMAGE_NAME:latest
docker tag $IMAGE_NAME:latest gcr.io/$PROJECT_ID/$IMAGE_NAME:$GIT_TAG
docker push gcr.io/$PROJECT_ID/$IMAGE_NAME:latest
docker push gcr.io/$PROJECT_ID/$IMAGE_NAME:$GIT_TAG
Here is an error where I am stuck with:
GitHub Actions
/ .github/workflows/gcp.yaml
Invalid workflow file
You have an error in your yaml syntax on line 15
I tried all possible indentations available on the internet but had no luck. I tried Yamllinter but still could not find where the error comes from. Please point me to where I am going wrong.
Thanks.
The runs-on (not runs_on) should have two spaces indentation relative to the job identifier. Also, the OS should be ubuntu-latest.
Then, env should have the same indentation as runs-on or name, the same as steps.
Here is the correct WF:
---
name: Build and push python code to gcp with github actions
on:
push:
branches:
- main
jobs:
build_push_grc:
name: Build and push to gcr
runs-on: ubuntu-latest
env:
IMAGE_NAME: learning_cicd
PROJECT_ID: personal-370316
steps:
- name: Checkoutstep
uses: actions/checkout#v2
- uses: google-github-actions/setup-gcloud#master
with:
service_account_key: ${{ secrets.SERVICE_ACCOUNT_KEY}}
project_id: ${{ env.PROJECT_ID }}
export_default_credentials: true
- name: Build Docker Image
run: docker build -t $IMAGE_NAME:latest .
- name: Configure Docker Client
run: |-
gcloud auth configure-docker --quiet
- name: Push Docker Image to Container Registry (GCR)
env:
GIT_TAG: v0.1.0
run: |-
docker tag $IMAGE_NAME:latest gcr.io/$PROJECT_ID/$IMAGE_NAME:latest
docker tag $IMAGE_NAME:latest gcr.io/$PROJECT_ID/$IMAGE_NAME:$GIT_TAG
docker push gcr.io/$PROJECT_ID/$IMAGE_NAME:latest
docker push gcr.io/$PROJECT_ID/$IMAGE_NAME:$GIT_TAG
I would recommend debugging such issues in the GitHub file edit form (editing the yml file in the .github/workflows directory). It will highlight all the issues regarding the workflow syntax. Demo.

I can't able to upload an artifact to GitHub

there I am facing some issues with my workflow artefacts. The Error is
-(Error: Create Artifact Container failed: Artifact storage quota has been hit. Unable to upload any new artifacts )
I create a zip and then upload it to artefacts does not work. and I delete my old artefacts still I'm facing this issue. I tried so many ways to upload artefacts but nothing worked for me.
I'm sharing my workflow:
name: Build and Deploy My App
on:
push:
branches: [master]
workflow_dispatch:
jobs:
build:
name: Creating Build ⚒
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout#main
- name: setup Node Version To 16
uses: actions/setup-node#v2
with:
node-version: '16.x'
- name: Installing Packages 📦
run: npm install --legacy-peer-deps
- name: 🔨 Build Project
run: CI=false npm run build
- name: zip the build folder
run: zip release.zip ./build/** -r
- name: Archive production artifact
uses: actions/upload-artifact#v3
with:
name: my-app-build
path: release.zip
deploy:
name: Start The Deploying 🚀🤘
needs: build
runs-on: ubuntu-latest
steps:
- name: Download artifact
uses: actions/download-artifact#v3
with:
name: my-app-build
- name: unzip the build folder
run: unzip my-app-build
- name: All Good To Go ✔ start Sync files to hosting
uses: SamKirkland/FTP-Deploy-Action#4.3.3
with:
server: ${{ secrets.FTP_SERVER }}
username: ${{ secrets.FTP_USERNAME }}
password: ${{ secrets.FTP_PASSWORD }}

Github Actions - copy files to VPS

I would like to solve this at a small VPS Provider:
Github worflow, when pushed files to GitHub, then "GH workflows" copies the php files to the live VPS server.
How can I copy them?
.github/workflows/vps-deploy-prod.yml:
name: vps-deploy-prod
on:
push:
branches:
- master
jobs:
build: 'VPS Run Deploy'
runs-on: ubuntu-latest
steps:
- name: 'Checkout'
uses: action/checkout#master
- name: 'Deploy'
run: make vps-run-deploy
The Makefile:
##### VPS specific target
vps-run-deploy:
?? copy files via ssh scp...?
You might consider the GitHub action appleboy/scp-action
GitHub Action for copying files and artifacts via SSH.
Here is an example in this project: renatomh/gobarber-backend/.github/workflows/main.yml:
# Copy the repository to the directory on the server/VPS used for the application
- name: Copy dist to VPS
uses: appleboy/scp-action#master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
port: ${{ secrets.SSH_PORT }}
key: ${{ secrets.SSH_KEY }}
# Selecting all folders except "node_modules"
source: ".,!node_modules"
# The path is based on the directory where the user logged into the server starts
target: "~/app/gobarber-backend"

gh-pages deployment issue, job fails on deploy. The directory you're trying to deploy ... doesn't exist

gh-pages deployment fails with next error: My repository failed job
Checking configuration and starting deployment… 🚦
Error: The directory you're trying to deploy named /home/runner/work/azure-flask-react/azure-flask-react/dist doesn't exist. Please double check the path and any prerequisite build scripts and try again. ❗
Deployment failed! ❌
I'm trying to deploy ReactApp at Github and besides deploy Python-Flask backend hosted at Azure and back-app has its automatically generated job yml.
But for front-app I followed this answer and manually added second job in yml because I need to provide env.variables.
My backend deployment succeeds but front-app constantly fails because of duplicated path
/home/runner/work/azure-flask-react/azure-flask-react/dist
Here is my yml and package.json but there is no any extra mentioning of that directory...
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# More GitHub Actions for Azure: https://github.com/Azure/actions
name: Build and deploy Python app to Azure Web App - first-py-app
on:
push:
branches:
- main
workflow_dispatch:
jobs:
front-build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout#v1
- name: Build
run: |
npm --prefix front-app install
npm --prefix front-app run-script build
env:
REACT_DEV_SERVER_URL: ${{ secrets.REACT_DEV_SERVER_URL }},
REACT_DEV_FRONT_APP_URL: ${{ secrets.REACT_DEV_FRONT_APP_URL }}
- name: Deploy
uses: JamesIves/github-pages-deploy-action#releases/v3
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN_KEY }}
BRANCH: gh-pages
FOLDER: dist
back-build-and-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#master
- name: Set up Python version
uses: actions/setup-python#v1
with:
python-version: '3.8'
- name: Build using AppService-Build
uses: azure/appservice-build#v2
with:
platform: python
platform-version: '3.8'
- name: 'Deploy to Azure Web App'
uses: azure/webapps-deploy#v2
with:
app-name: 'first-py-app'
slot-name: 'production'
publish-profile: ${{ secrets.AzureAppService_PublishProfile_7edcdecca83a4354a87943f94bb32fca }}
{
...
"homepage": "https://nikonov91-dev.github.io/azure-flask-react",
"scripts": {
...
"predeploy": "npm run build",
"deploy": "gh-pages -d build"
},
}
and my file structure
azure-proj
|-front-app (containing reactjs)
|-package.json
|-node_modules
|-src
|-app.py (python-flask application which deploys successfully)
I misunderstood the issue message, the problem was not duplicating the problem was the missed inner path passed in FOLDER in gh-pages YML settings
There was a hint in BUILD step
And one more thing: do not forget to get and add to GH your personal-access-token