Copy JSON files from a private repository to the current one - github

I've set up a YML file for a GitHub action to get some files from a private repo I have. The action seems to work without throwing any error (even the file names are showing up in the log) but the folder and the files are not showing up in the destination repository.
Can someone shed some light on what am I doing wrong?
This is my YML so far:
name: copy JSONs
on:
push:
workflow_dispatch:
jobs:
copy_files:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- name: Copy files from private repo
uses: actions/checkout#v2
with:
repository: paramm/cron-jobs
token: ghp_BLABLABALBALBALBABLABLA
path: private-repo-files
- name: Create directory for copied files
run: |
mkdir copied-files
mv private-repo-files/*.json copied-files/
- name: Add and commit copied files
run: |
git config --local user.email "action#github.com"
git config --local user.name "GitHub Action"
git add copied-files
git commit -m "Add copied files from private repo"

last line was missing:
git push origin main

Related

GitHub Action errors because it can't see a folder

I'm trying to set up my first GiHub Action. All it needs to do is run a test over my Godot files. I based it on a template.
name: CI
on:
pull_request:
branches: [ main ]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: godot-tester
uses: croconut/godot-tester#v2.5
with:
version: 3.4
release_type: stable
# Give relative path to your project.godot, if not in top level of repo
path: app
The action errors every time, when trying to find the project file.
/entrypoint.sh: line 166: cd: ./app: No such file or directory
The folder, app, is there and it contains the project. I've tried with or without a trailing slash, it makes no difference.
When you need to access the files from the proper repository in a Github Actions workflow, you need to setup the actions/checkout first.
This will allow the workflow to access the Github workspace (which is basically the repository root).
In your case, the workflow should look like this:
name: CI
on:
pull_request:
branches: [ main ]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v3
- name: godot-tester
uses: croconut/godot-tester#v2.5
with:
version: 3.4
release_type: stable
# Give relative path to your project.godot, if not in top level of repo
path: app
The actions/checkout action has a default behavior, but you can also configure other fields to customize what you want it to do. Check the action README page to see all the possibilities.

Auto unzip files & deploy to Heroku from Github

I have a simple PHP + SQlite app working on Heroku with this structure:
myPhpApp/
├── Procfile
├── README.md
├── composer.json
├── composer.lock
├── data
│   ├── css.css
│   ├── small_db.sqlite3
│   ├── large_db.sqlite3.zip
└── index.php
The Procfile file simply contains: web: vendor/bin/heroku-php-apache2
Since my Github account limits file size, so I have to zip large_db.sqlite3 to large_db.sqlite3.zip .
What Inam trying to do is to auto unzip large_db.sqlite3.zip back to large_db.sqlite3 when I deploy it to Heroku through Github action.
So far I saw this code snippet:
# From https://github.com/marketplace/actions/deploy-to-heroku
name: Deploy
on:
push:
branches:
- master # Changing the branch here would also work
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- uses: akhileshns/heroku-deploy#v3.7.8 # This is the action
with:
heroku_api_key: ${{secrets.HEROKU_API_KEY}}
heroku_app_name: "YOUR APP's NAME" #Must be unique in Heroku
heroku_email: "YOUR EMAIL"
Is it possible to do something like this (pseudo code) in Github Action?
cd ./data
unzip large_db.sqlite3.zip
cd ..
deploy/build (on Github/Heroku)
May you all be well and happy!
Thanks!
After a process of trials & errors, I came to this solution.
I shared it here for future visitors. May it be helpful.
Github action yml file: .github/workflows/main.yml
# From: Github action template
# This is a basic workflow to help you get started with Actions
name: CI
# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [ main ]
pull_request:
branches: [ main ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout#v2
# Unzip and remove zip files
- run: unzip -qq './data/*.zip' -d ./data && rm ./data/*.zip
- uses: akhileshns/heroku-deploy#v3.7.8 # This is the action
with:
heroku_api_key: ${{secrets.HEROKU_API_KEY}}
heroku_app_name: "YOUR APP's NAME" #Must be unique in Heroku
heroku_email: "YOUR EMAIL"
Note:
For each zip file (separated zip files should be more flexible for your later updates, try not to bundle all in one big zip file), for my case, I compressed each file with this command: zip large_db.sqlite3.zip large_db.sqlite3
heroku_app_name is the appname in your https://appname.herokuapp.com

Folder missing in artifact - GitHub Actions

I have the following steps to copy files to artifact and publish artifact:
- name: copy FA function arm templates
run: Copy 'Service/Project/Hosts/FA/Infrastructure/' 'upload/functions_arm_templates/FA/Infrastructure'
shell: powershell
- name: copy FB function arm templates
run: Copy 'Service/Project/Hosts/FB/Infrastructure/' 'upload/functions_arm_templates/FB/Infrastructure'
shell: powershell
- name: publish artifact
uses: actions/upload-artifact#v2
with:
name: ${{github.run_number}}
path: upload/**
The Build succeeded however after downloading the artifact, I don't see a folder named functions_arm_templates. What am I missing?
You are only copying the folder without its contents.
Use copy 'Service/Project/Hosts/FA/Infrastructure/' 'upload/functions_arm_templates/FA/Infrastructure/' -recurse to copy the folder with its contents.

How to set Travis-CI deploy only release-* tags?

I have a question for Travis with Github-page.
I set up CI successful for build and deploy to Gh-page but that will deploy all commit.
deploy:
provider: pages
skip-cleanup: true
github-token: $GITHUB_ACCESS_TOKEN
target-branch: gh-pages
local-dir: dist
on:
branch: master
In some documents I found, that said add tags: true, But that will set up Travis to build all tags when I push tags to master branch.
deploy:
provider: pages
skip-cleanup: true
github-token: $GITHUB_ACCESS_TOKEN
target-branch: gh-pages
local-dir: dist
on:
branch: master
tags: true
And I would like to build some specific tags like release-*, dev-*, test-*, so on...
So, How to config to do that with Travis.
Thanks.

Github include md files in README.md?

Is there a way in Github to include md files in for example the README.md?
# Headline
Text
[include](File:load_another_md_file_here.md)
It should not link to the file, it should load the contents from it, like PHP include / file_get_contents.
That does not seem to be possible, especially when considering github/markup#346 and github/markup#172.
No include directive is supported.
This is not the correct answer but a workaround for others who really want this.
It's possible to use Gulp and Gulp Concat to merge the files into one before they are sent to Github..
Since it is not possible I just ended up placing a link as
[MY-LINK](../../SOME-OTHER-README.MD)
migrate your readme to a different file then construct your actual README however you like as a github action
EDIT: Here's a demo that you can build off of. This repo has a single github action that runs a script that dynamically builds the README.md based on the contents of the repository (to build a site map for the repo in the form of a table of contents): https://github.com/dmarx/bench-warmers
the workflow config:
name: update-readme
on:
push:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v3
- uses: actions/setup-python#v2
- name: Run the script
run: python scripts/update_readme.py
- name: Commit files
run: |
git config --local user.name "dmarx"
git add README.md
git commit -m "Updated TOC"
- name: Push changes
uses: ad-m/github-push-action#master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
force: true
Here's the chunk of my update script that's relevant to you:
... # code that builds the object `toc_str`
# template readme
with open('README.stub') as f:
readme_stub = f.read()
# simple replacement, use whatever stand-in value is useful for you.
readme = readme_stub.replace('{TOC}',toc_str)
with open('README.md','w') as f:
f.write(readme)
Which assumes you have a file named README.stub which might look something like this:
# Title
some text
{TOC}
more text
Where {TOC} is the substitution target for our dynamic content.
Ruby gem markdown_helper implements include files for GitHub flavored markdown (GFM).
Disclosure: I wrote the gem.