Redeploy a branch in a site with the latest git commit using Netlify API - deployment

I use Gridsome for Static Site Generation and I integrated Bitbucket with Netlify, so when I add a new commit it directly redeploys my site with the latest commit.
Sometimes I need to redeploy without any changes in the project files, just to get the latest changes in the Database.
I want to add a button to my site when click, it uses Netlify API for redeploying with the latest Git commit, How can I do that with Netlify API?

To get the same behavior of redeploying with last commit or last deploy
First, I have to get the last deploy id for this branch
const deploys = await this.$axios.get(`https://api.netlify.com/api/v1/sites/***siteId***/deploys?page=1&per_page=1&branch=***branchName***`, {
headers: {
"Authorization": `Bearer ${token}`
}
});
Then we retry this specific deployment with this code.
await this.$axios.post(`https://api.netlify.com/api/v1/deploys/${deploys.data[0].id}/retry`, {}, {
headers
})

Related

helm repo via gh-pages does not reflect latest published charts

I'm using gh-pages to serve as a helm chart repo. At one point, it was working fine. Now, it doesn't. I package the chart, upload it, and update and push the index.yaml file in the gh-pages branch. I can go to the gh-pages url (effectively, the repo url) and examine the index.yaml file...I see the updated version listed there. I can copy the file url from index.yaml and the tgz downloads successfully. Looking inside the tgz, it has the correct version in Chart.yaml. All seems well.
But, when I run helm repo update [repo], none of the recent versions will show up. helm repo search shows only older versions. I've verified that the repo url is correct...it's the same one that I'm able to pull the valid index.yaml file from. I've also tried just upgrading a release using one of the newer 'missing' versions and it complains that it can't find the chart.
What am I forgetting?

How do I programatically download the ZIP file for a GitHub repo's default branch?

I'm writing a PHP script that lets users enter a GitHub owner & repo name, and then it downloads a zip file from that repo.
GitHub allows linking directly to the download of the latest release for a repo: /owner/name/releases/latest/download/name.zip (see https://docs.github.com/en/free-pro-team#latest/github/administering-a-repository/linking-to-releases). So if a repo has a release, that works fine.
However, for repos without a release, I want to download from the default branch instead. GitHub provides a link for this (green 'Code' button > 'Download ZIP'), but that URL includes the branch name: /owner/name/archive/[BRANCH].zip.
Is there a way to link directly to the download for the latest branch without knowing what the branch might be called? For example, something like this hypothetical URL: /owner/name/archive/latest.zip
You would need to read the default branch of the repository first through GitHub API (See Get Repository)
Once you have the default branch, you can use it to complete your download URL
curl -L http://github.com/<user>/<repo>/archive/<branch>.zip --output <branch>.zip
Unless you need the default branch name for something, you can do this in one call.
https://api.github.com/repos/<user>/<repo>/zipball

How can I pull a new branch from GitLab in Eclipse in an existing project

I just started to work with Eclipse and GitLab. In Eclipse I pulled my ABranch. Now I created an extra branch in GitLab, but I can't get the new branch in Eclipse.
I created a project in Gitlab with 2 branches (Master and Abranch).
In Eclipse I only pulled the Abranch and pushed the changes back.
In Gitlab I merged the changes to Master and also added an extra branch (testtesttest).
Now I try to recieve the other branches in Eclipse.
Can you help me without using commands?
In tried to fetch from upstream with right-click at my repository but I can only see my 'origin/Abranch' under Remote tracking. I can't get my Master and Testtesttest in.
Fetching says everything is up to date.
I've got a screenshot below.
Screenshot (empty) fetch results, here I expected my Master and Testtesttest
Try git fetch in your project root location.
After all a bug in Eclipse was likely the issue.
I also had Eclipse freezing at some moments. It's fixed with the following update:
https://www.eclipse.org/forums/index.php/t/1099477/

Connecting github repository with my webpage

Hey how to connect my webpage with github repository ,I mean , when I merge pull request it immediately make change in my webpage.I was using github-pages but now I would like include some php and it doesn't work. Thanks for any help.
Manual: after each push to the repo you´d have to pull on your server for the current version. (You don´t want this...)
Automation: first you need a server (linux/ windows) with git installed and clone the repository to your webserver directory (i.e. apache.webserver: var/www/html). Then you need a script which automaticly pulls the new changes to your server and use a webhook to trigger the script. That way you´d have the current version of your repo on the server all the time. (Push --> Webhook triggers script --> Server repo get´s new changes)
Alternative: create NOT a github BUT a git repository hosted on your own server (tuturial for linux only). You could push into it aswell and you´d have the current version of your site on the server without the path over github.

Moving my public NPM package from Bitbucket to Github

I like Bitbucket better than Github, but sadly there's only very few options for continuous integration for Bitbucket.
The packages in question are written by me, and are currently hosted on Bitbucket:
https://www.npmjs.com/package/grunt-asset-compress
https://www.npmjs.com/package/node-file-parser
I want these to be moved to Github, without breaking anything. I am afraid changing the repository data is not enough.
"repository": {
"type": "git",
"url": "https://StephanBijzitter#bitbucket.org/skelware/grunt-asset-compress.git"
},
Image a user has version 1 installed, which is hosted on Bitbucket.
I then change the version to 2 and change the URL to the Github URL.
I proceed to push, to both Github and Bitbucket.
If the user updates, he will be updating to version 2, which by now includes the URL of Github.
I push some more fixes and release version 3 on Github, the user updates again and everything is fine.
However, what if the user did not update to version 2, before version 3 was released? NPM will probably try to download version 3 from Bitbucket as that is what the URL points to in version 1!
I do not want to keep the repositories in sync; I want to be able to make the Bitbucket repository private at one point to hide it from public view while the Github repository would then serve on its own.
What are the steps I need to take to be able to move to Github, without breaking the update system for the (albeit limited) users of my packages?
Just got a reply from NPM itself:
Hi, Stephan.
Thanks for the question. I'm hoping I can help...if I'm understanding
your inquiry correctly.
What ever you publish to npm is held within our own repository and
that is what's served to a user when they install your package. The
inclusion of the repository url, bitbucket or github, is more
informational as opposed to functional. Regardless of when you push
changes to github, the user that installs your package will get your
latest publish to npm. In other words, those two things may be in
different states and at different versions.
Please let me know if I'm off base. I'll be here to help. Ernie
In other words, for all I care I could remove the Bitbucket repository entire and nothing will break, as a copy is hosted on their servers which is served to everyone downloading it through NPM.
Thank you, Ernie!