How do I define a GitHub action? - github

I'm trying to play around with GitHub actions but I'm having a hard time just have it to start.
As a first step, I have copied the following workflow on a brand new repo.
https://help.github.com/en/articles/creating-a-docker-container-action#example-using-a-private-action
But I get a parsing error
https://github.com/inforlife/action-test/blob/master/.github/main.workflow
https://raw.githubusercontent.com/inforlife/action-test/master/.github/main.workflow?token=AA3RFK7OVCNLSMBMVHK6GB25SKZRQ
Am I missing anything here?

The .github/main.workflow HCL format is GitHub Actions version 1. This version no longer works. GitHub Actions version 2 uses yaml format workflows under .github/workflows/.
Try starting with these starter workflows
https://github.com/actions/starter-workflows

You mentioned .github/main.workflow
The documentation suggests:
.github/workflows/main.yml
Adding that main.yml with .github/workflows/ should work better.

Related

use github action workflow file of another repository

I have multiple repositories with the same github-actions build job.
Currently I duplicate the workflow files, but it is the same between all the repositories, so if I could do an import it would be better.
How can I import the same workflow file in all those repositories?
It looks that at the moment there is no out-of-the-box support for this. Please check this issue.
But you can take a look on GFlows - GitHub Workflow Templates
GFlows is a CLI tool that makes templating GitHub Workflows easy, using either Jsonnet or ytt (Yaml Templating Tool). It can:
Import existing workflows to help you quickly get started.
Validate GitHub workflows are up to date with their source templates and conform to a valid schema.
Share common config code and workflows with GFlows Packages.
Watch changes to the templates, so you can develop and refactor workflows with fast feedback on your changes.

How to create github PRs from Jenkins pipeline?

I'd like to make a new git branch, add a commit, and then push to github. In addition, it would be great to create a PR for that branch straight from Jenkins job.
Has anyone done it yet? The part I'm struggling is how to create a PR. For creating a branch and commit, I'm running regular git commands in the shell.
Thanks, N.
Sounds like you want the pipeline multi branch plugin there's a blog here https://jenkins.io/blog/2015/12/03/pipeline-as-code-with-multibranch-workflows-in-jenkins/ that might help too. We use this plugin on the fabric8 project and it works great.
Correction: I misread the question initially. We use a shared pipeline library that contains reusable functions to make pull requests. This is an example where we make version update PRs on downstream repos once a release has finished. The groovy code that interacts with the github api is here

VSTS Filter by repository folder?

I'm using Visual Studio Team Services to build my project which is stored in GitHub (here). The master branch contains multiple projects which make up the solution. Amongst those are a WebAPI project and a Cordova project. I need to build those using two separate build definitions in VSTS.
Previously I had set-up my build definition and used the branch filters to filter on what had been pushed to the repo. For instance:
master/src/API
This worked, but it doesn't any more. It seems as if the underlying code has changed. A filter of 'master' still works and I understand how this feature is probably meant to filter specifically on branches and maybe not on folders within the branch?
It's not a huge problem, but at this time all of my builds will trigger with every check-in, even if nothing changed in the meantime for that source code. So I'm not wondering what a good solution for this issue would be:
Put every project in it's own branch. Seems like a workaround
Some other filter option or maybe another syntax or something?
Leave it as it and don't worry about the extra builds (but that itches, you know...)
Anyone running a similar set-up?
Path filters is not supported for VSTS GitHub CI Build, it is available for Git CI Build on VSTS. You can vote this user voice: https://visualstudio.uservoice.com/forums/330519-team-services/suggestions/15140571-enable-continuous-integration-path-filters-for-git
The workaround is as you said that put every project in its own branch.

How to create tag automatically upon accepted merge request in GitLab?

This is for a repository containing a library. The library version number is incremented (manually) each time a Merge Request to master is accepted.
However, if I want to access a file from version X.Y.Z, I have to look for the commit that incremented the version number to X.Y.Z, get its date, and then look in the history of the file for the version at that date.
I would like to create a tag per version, automatically when the Merge Request to master is created. Is this possible?
I hoped it would be possible with the new GitLab slash commands, but there currently is not support for tags.
Is there any other possibility than using web hooks?
While facing the same challenge, I stumbled upon this suggestion on GitLab's former issue tracker on GitHub1:
“You can write up a script to use GitLab API to accept a merge request, get the commit of the merge and then tag that commit.” --MadhavGitlab
(just to mention that — for me that's not sufficient)
1 EDIT:
Looks like all issues have been purged from the GitHub mirror, so this link does no longer work, but luckily the relevant quote persists right here.
I first tried to do it the gitlab way, by creating a .gitlab-ci.yml file in the project top-level directory. That file can contain the commands creating the version tag. The user executing the script has to have enough permission to push to the git project, and be configured with authoring information.
I finally did it on a Jenkins server, where I created a job that is invoked when commits are pushed into a specific branch. The tag can be created in the execute shell commands.

Is there a way to import Jira issues to GitHub?

I've tried exporting issues from both GitHub and Jira to CSV files, but I've never tried exporting Jira issue then importing it to GitHub, is this possible? If so, what would be the best way to approach something like this?
There is simply not a "Import issues from JIRA" feature in GitHub.
The way I see it you have two options, either to integrate your current JIRA instance with GitHub or migrate the JIRA issues into GitHub issues using your own criteria and migration script.
GitHub and JIRA Integration
I would very much like to add all the instructions here but it's one of those cases where a link to the documentation makes much more sense.
There's also a video on youtube which is quite short and easy to follow.
Migrating JIRA issues into GitHub Issues
In order to do this you would have to write your own script that reads issues from the JIRA REST API and creates new ones using GitHub Issues REST API.
Note that JIRA and GitHub issues are different in nature, so your script would have to choose how to migrate one type of issue to another.
I hope this helps.
Another way is to export the JIRA issues as XML file.
The following project provides Python 2 scripts to import such a file into a GitHub project via its REST API:
https://github.com/hbrands/jira-issues-importer
Besides issues with comments, it imports milestones, labels and components as labels. References to issues in comments are to some degree converted. Also, JIRA relationships like "blocks" and "depends on" are migrated to special issue comments in GitHub.
It avoids the problem of running into abuse rate limits by using a special Issue Import API.
Please read the sections about the features, caveats, assumptions and prerequisites on the project site. Be sure to test the issue migration with a GitHub test project first.
Here are the things you need to do for export from JIRA and import to GitHub.
First export issues (to a csv file) from JIRA with the feilds you need.
Then read the csv file line by line and use the github api to create issue in GH.
https://github.com/susinda/github-client/blob/master/src/main/java/org/wso2/git/client/GitRestApiExecutor.java
Here is a sample client to do the job[1], readme contains the steps,feel free to modify it and use if that does not match with your requirement https://github.com/susinda/github-client
Try this node module https://github.com/gavinr/github-csv-tools, need to download issue form Jira and use this to upload on GitHub.
https://github.com/parcelLab/jira-to-github is a (pretty old) project to migrate JIRA issues to Github.
Export the issues from JIRA
First, create a full export to XML as described in this guide:
https://confluence.atlassian.com/adminjiracloud/exporting-issues-776636787.html
You'll need the exported entities.xml from JIRA to upload the
issues to your GitHub repository using the GitHub API.
Run the import to GitHub
Run node index.js to use the script