I get a 400 status code error from a GitHub Pages deployment - github

During an automated "pages build and deployment" workflow, I get the following error:
Error: Request failed with status code 400
This is just a static site, no jekyll or anything like that (I have a .nojekyll file in the root) and it's worked fine for several years until today.
I've opened a ticket on GitHub support, but in case anyone here can help me in the meantime... Is there anything I can do to try to resolve this?

It could be the side-effect of (from two days ago)
GitHub Pages: using GitHub Actions for builds and deployments for public repositories
Today you will begin to see a new workflow running called pages build and deployment in your public GitHub Pages repositories.
This workflow is automatically triggered when you push to the branch configured for GitHub Pages in your repository.
As the name suggests, it builds and deploys your pages site.
The initial benefit of this change is enabling you to see your build logs and any errors that may occur which has been a long standing issue for Pages users.
However, in the future this will enable us to give you the ability to fully customize your pages build and deployment workflow to use any static site generator you want without having to push the build output to a special branch of the repository.
You may notice this workflow uses some new actions actions/pages-deploy, and actions/jekyll-build-pages.
For now these actions are designed to be used in the generated workflow, however, starting early next year we will introduce some additional changes that will enable you to take advantage of them.
Learn more about GitHub Pages
So Cecilapp/GitHub-Pages-deploy (the GitHub Pages deploy) workflow you might be using) might behave differently in light of those recent changes.

Related

How to automatically deploy main branch changes to staging site using Github Actions

I'm collaborating on a website using Github for source control. The site is hosted on a shared server on Dreamhost. I'd like to set up an easy way for myself and my collaborator to be able to see changes that have been merged into the main branch on the staging site then also run a couple of other shell commands (composer update, for example, after deploying the changes).
I'm new to this. I've found pieces of relevant documentation but have not been able to tie it all together. So far I am running into at least two issues.
Setting up github environments to point to development and staging environments
I looked into Github Workflows but it seemed Github Actions might be easier. I set up Github Environments called staging and development. When setting up the environments, I saw the option to add environment secrets but don't know what exactly to add here. So my environments in Github have names but don't really point to my development and staging environments. I think the first thing I need to figure out is how to link my Github Environments and actual development and staging environments together. I found Deploying with Github Actions but didn't find an answer there.
Invalid workflow file error
Also I found an action in Github Marketplace called branch-deploy. I created a yaml file under .github/workflows to test it. When this runs, I see an error on the workflow in Github of
Invalid workflow file
The workflow is not valid. .github/workflows/deploy.yml (Line: 2, Col: 1): Unexpected value 'id'
Not sure what is going on with this error because the "basic usage" example in the Marketplace page uses the same value for id.

Deploy site to GitHub pages after an action has been ran [duplicate]

This question already has answers here:
How to force GitHub Pages build?
(11 answers)
Closed 2 years ago.
Situation
I am using GitHub Pages to display a simple landing page for my project with direct download links to artifacts generated by a GitHub Action. This information is pulled from the GitHub API via this syntax in the GitHub Pages index.md:
[Download Installer (Windows)]({{ site.github.releases[0].assets[1].browser_download_url }})
When I push to the master branch, I run an action that automatically releases new binaries as GitHub Releases. Unfortunately, the GitHub Pages page is being deployed at the same time, with the GitHub API still providing the previous release as the latest release.
GitHub Pages configuration
Deployment page:
Question(s)
How can I tell GitHub to only trigger a deployment of the GitHub Pages page after the release action has completed? Does an Action exist to trigger what GitHub seems to do automagically after each push? And is there a way to disable the automatic deployment so that the page only gets deployed after a (successful) release?
The only action keep getting to when googling is peaceiris/actions-gh-pages, but it seems to have been made to deploy web projects to GitHub Pages. Am I correct in thinking this, or is there a way to use this action to accomplish what I described?
I'm not sure about GitHub's automagic Pages deploy, but if you're somehow able to replicate that into a job of its own in your workflow file, you can use the needs attribute to make the deploy job depend on the release job completing. The 2 jobs must be defined in the same .yml workflow file.

What are github actions minutes/month?

Can you please give a clear explanation, maybe with an example, as to what does github mean when saying that a plan includes 2000 actions minutes/month? If I execute a git pull does this count as one action? How actions connect to minutes? The time I take to pull some commits from a repo counts towards the minutes I have?
I am aware of SO answers (like this) that may tell someone how to calculate the time remaining but I don't really understand what an action is.
For example, say I have a repository with some python/js code and I start working on a new system. When I do a git pull to clone my repository in this new system are there any actions in the backstage that are consumed? Do I consume any time from my plan? This is what I haven't clarified and needed maybe some simple examples to demonstrate. Thanks!
GitHub Actions is a feature provided by GitHub to create workflows which can run on triggering any GitHub event, for eg run the build of the project on creation of a pull request. GitHub actions can be configured by creation of a workflow in the form of a yaml file and placing it under .github/workflows directory in your repo. This documentation provides more info regarding creating workflows.
For example, say I have a repository with some python/js code and I start working on a new system. When I do a git pull to clone my repository in a new system are there any actions in the backstage that are consumed? Do I consume any time from my plan?
No, running a git pull to clone your repo doesn't use up any allocated action minutes.
GitHub actions only run if you have configured them to run by creating the workflows for specific GitHub events as mentioned here. When any actions are configured for a repo, the same can be viewed under the Actions tab as shown below. Every GitHub action triggered shows up here.
Also, the current 2000 action minutes per month allocation is for the triggered workflows for private repos, not public repos. You can check your usage of the free action minutes for private repos at https://github.com/settings/billing, as mentioned in my SO answer here .
That relates to Github Actions, not things like pushing, pulling etc.

How to display a VSTS Build Badge in a README.md file hosted on GitHub?

I have developed a tiny library that I chose to host on GitHub. The code is being built by a VSTS build and published as a NuGet package.
I have written a README.md file and I am trying to include a Build badge on it, as described in the Microsoft documentation. Consequently, I have added the following line in the MD file and replaced the placeholders accordindly:
![Build status](https://{my-organisation}.visualstudio.com/{my-project}/_apis/build/status/{my-build-definition-name}?branch=master)
The problem is that the link is not accessible to anyone that is not logged-in on VSTS and I end up with a 'broken' link on my readme page:
Question
What must be done to make the VSTS Build Badge available to a GitHub repo?
I suppose you must include an authentication token of sorts in order to have at least read-access to the VSTS build from your GitHub page.
Note that the documentation lists also multiple pending issues, including MicrosoftDocs/vsts-docs issue 1499:
Build status badge added to GitHub readme doesn't show up.
So this is still in progress.
On that last issue, it says:
This is due to public vs. private projects.
If you make your project public the image URL will render.
There are other potential workarounds we are looking at for the doc.
See "Change the project visibility, public or private".

How to stop TeamCity from building a pull request when it is viewed or commented?

Currently, my team is using TeamCity to automatically build pull requests from GitHub.
We have a configuration to build all the pull requests. In the version control settings of the config, our branch specification is
+:refs/pull/*/merge
In the "Build Triggers" configuration setting, we have only one trigger with the following trigger rule:
+:root=Pull Requests on our Repository:\***/*\*
"Pull Requests on our Repository" is our VCS root name.
The issues:
When someone views a pull request on GitHub website without doing anything else, a build would be triggered in the TeamCity build agent. This is quite annoying, because from time to time, we have multiple build agents building the same pull requests (when multiple people view it).
When someone comments on a pull request, a build would also be triggered.
From my perspective, the only time I want TeamCity to start a build is when new commits are pushed to the pull requests.
Is there a way to do it?
Github's refs/pull/*/merge branches are updated every time mergeability of the branch is recalculated, i.e. on every commit to destination (most likely master) branch. They are also updated when pull request is closed and then reopened. Github's support says these branches are not intended for end users use. The only workaround at the moment is to run builds on refs/pull/*/head branches automatically and on refs/pull/*/merge branches manually.
Do you have TeamCity configured as per this blog post? I then activate the TeamCity service hook in GitHub which takes care of triggering a build in TeamCity whenever there is a push. This seems to do the right thing for me. Or am I missing something?
I know this is old but I wanted to post what we've found as alternatives:
Stop using VCS roots altogether as a mechanism for triggering pull requests. Instead, configure a GitHub webhook to notify a web app of yours whenever there is an update to a PR and only then trigger a build via the TeamCity REST API.
In your build config, add a step that checks what changed in the PR. If nothing changed (i.e. no new commits were added), or if the PR is closed, cancel the build. The problem with this is that the build queue will still be populated with builds that will then be cancelled. Also, you'd have to store somewhere the last commit that was built in order to do the check.
According to their TeamCity's issue tracker, the issue of the TeamCity.GitHub plugin causing an infinite loop of builds was fixed in v9.0