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

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.

Related

Copy JSON files from a private repository to the current one

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

Azure DevOps Pipeline Resource.Repository Trigger is not working

I have two repos named Project1 and Project2 with two branches main & dev and my default branch is main.
I have one build pipeline for Project1 named project1pipeline, it will be triggered by the main & dev branches. I added Project2 as resources.repositories.repository code in the YAML file of Project1. Whenever the commit happened in both of the repos of the main(default branch), it triggers the project1pipeline
When I commit some changes in the dev branch of the Project1 repo, it triggers the project1pipeline but When I commit some changes in the dev branch of the Project2 repo, it doesn't trigger project1pipeline.
Project1 YAML file for the main branch
trigger:
branches:
include:
- main
pool:
name: default
resources:
repositories:
- repository: proj2
type: git
name: DevOps/Project2
ref : 'refs/heads/main'
trigger:
branches:
include:
- main
workspace:
clean: all
steps:
- checkout: self
clean: true
- checkout: proj2
clean: true
- task: CopyFiles#2
inputs:
SourceFolder: '$(Build.SourcesDirectory)'
Contents: '**\*.txt'
TargetFolder: '$(Build.ArtifactStagingDirectory)'
Project1 YAML file for the dev branch
trigger:
branches:
include:
- dev
pool:
name: default
resources:
repositories:
- repository: proj2
type: git
name: DevOps-Test/Project2
ref : 'refs/heads/dev'
trigger:
branches:
include:
- dev
workspace:
clean: all
steps:
- checkout: self
clean: true
- checkout: proj2
clean: true
- task: CopyFiles#2
inputs:
SourceFolder: '$(Build.SourcesDirectory)'
Contents: '**\*.txt'
TargetFolder: '$(Build.ArtifactStagingDirectory)'
Note: Both the repo in the same project
This is an expected behavior in Azure Pipeline with resource trigger.
From my test result, the branch resource trigger works corresponding with the default branch set for Project1. Current default branch is main.
Here is the test process:
Project1 dev:
Project1 main:
The pipeline using this .yml file will be triggered by commit from:
-Project1 dev
-Project1 main
-Project2 main
Refer to this official doc:https://learn.microsoft.com/en-us/azure/devops/pipelines/process/resources?view=azure-devops&tabs=schema
If you change Project1 default branch to dev.
The pipeline using this .yml file will be triggered by commit from:
-Project1 dev
-Project1 main
-Project2 dev

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.

Travis CI deploy JAR to Github master

Refs: http://docs.travis-ci.com/user/deployment/ and http://docs.travis-ci.com/user/deployment/releases/
I'm tring to deploy my JAR file to Github, but I don't want to create a tag every time.
I know it is not the correct behaviour, but I want to do this way if possible.
Building process is running fine, but when I use this travis.yml file:
language: java
deploy:
provider: releases
api-key: "<my_api_key>"
file: "teapot-1.2.5-beta.jar"
skip_cleanup: true
on:
branch: master
I got this error:
Installing deploy dependencies
Fetching: addressable-2.3.6.gem (100%)
Successfully installed addressable-2.3.6
Fetching: multipart-post-2.0.0.gem (100%)
Successfully installed multipart-post-2.0.0
Fetching: faraday-0.9.1.gem (100%)
Successfully installed faraday-0.9.1
Fetching: sawyer-0.6.0.gem (100%)
Successfully installed sawyer-0.6.0
Fetching: octokit-3.7.0.gem (100%)
Successfully installed octokit-3.7.0
5 gems installed
Fetching: mime-types-2.4.3.gem (100%)
Successfully installed mime-types-2.4.3
1 gem installed dpl.2
Preparing deploy
Logged in as Carlos Magno Oliveira de Abreu
Deploying to repo: icemagno/teapot
Current tag is: dpl.3
Deploying application
/home/travis/.rvm/gems/ruby-1.9.3-p551/gems/octokit-3.7.0/lib/octokit/response/raise_error.rb:16:in `on_complete': POST https://api.github.com/repos/icemagno/teapot/releases: 422 - Validation Failed (Octokit::UnprocessableEntity)
Error summary:
resource: Release
code: missing_field
field: tag_name
resource: Release
code: custom
field: tag_name
message: tag_name is not well-formed
resource: Release
code: custom
message: Published releases must have a valid tag // See: https://developer.github.com/v3/repos/releases/#create-a-release
...
failed to deploy
This is the basic deploy config:
language: java
deploy:
provider: releases
api-key: "<my_key_again>"
file: "teapot-1.2.5-beta.jar"
skip_cleanup: true
on:
tags: true
all_branches: true
But I have not created any tag because I don't want to do this for now.
EDIT
I've created a tag, now I need to change .travis.yml file to test some configurations and GitHub is not allowing me to change anything on tag files (ok, must be this way) cr#p !
If I may, I believe what you are looking for is the same as I was.
Basically add something like the following to your .travis.yml:
before_deploy:
- git config --global user.email "builds#travis-ci.com"
- git config --global user.name "Travis CI"
- export GIT_TAG=$TRAVIS_BRANCH-v0.1.$TRAVIS_BUILD_NUMBER
- git tag $GIT_TAG -a -m "Generated tag from TravisCI for build $TRAVIS_BUILD_NUMBER"
- git push -q https://<your-api-key>#github.com/<your_name>/<project_name> --tags
deploy:
skip_cleanup: true
provider: releases
api_key:
secure: [redacted]
file:
- "your_file"
on:
tags: false
all_branches: true
branches:
except:
- /^*-v[0-9]/
Careful doing this though, as messing up while working with these particular config options might lead to an infinite Travis-CI build loop, which will pollute your build and tag history, and not be easy to cleanup.

How to deploy to github with file pattern on travis?

I have created a simple travis configuration which packages an app and tries to deploy the archive file to github.
The problem is, I would like to have the version number part of the file name, so i require to use a pattern for the filename. I simply can't get it to work.
Configuration is currently:
deploy:
provider: releases
file: "build/distributions/worktrail-app-hub-sync*.zip"
on:
repo: worktrail/worktrail-app-hub-sync
tags: true
all_branches: true
But it fails with: "/home/travis/.rvm/gems/ruby-1.9.3-p547/gems/octokit-3.3.1/lib/octokit/client/releases.rb:86:in `initialize': No such file or directory - build/distributions/worktrail-app-hub-sync*.zip (Errno::ENOENT)" - but the file is certainly there: build/distributions/worktrail-app-hub-sync-0.0.1.zip
Example run: https://travis-ci.org/worktrail/worktrail-app-hub-sync/builds/35704111
travis.yml: https://github.com/worktrail/worktrail-app-hub-sync/blob/0.0.1/.travis.yml
Is this supported by travis deployment, or is there any workaround for this use case?
Wildcards are supported by now if you enable the file_glob option. This is how I deploy a build .deb file to GitHub releases:
before_deploy:
- export RELEASE_PKG_FILE=$(ls *.deb)
- echo "deploying $RELEASE_PKG_FILE to GitHub releases"
deploy:
provider: releases
api_key:
secure: YOUR_ENCRYPTED_API_KEY
file_glob: true
file: "${RELEASE_PKG_FILE}"
on:
tags: true
Setting up is easy by executing travis setup releases with a dummy filename and modifying .travis.yml afterwards.
deploy:
file_glob: true
file: "build/distributions/worktrail-app-hub-sync*.zip"
example
Sorry, wildcard patterns don't work at the moment, but we'll have a look into making that possible on Travis CI.