Can github actions automatically open web pages? - github-actions

My requirement is to automatically open a web page every 5 hours (for example: www.xxx.com, I don't need to see the content of this page, just open it). The page takes 3 minutes to load, and then just close the page.
Can I use Github Actions to achieve my requirement?

Yes, this technically possible. GitHub Actions has the on.schedule event which allows you to essentially set up a cron schedule for execution of your workflow. Your cron schedule for running the workflow every 5 hours would be something like 0 0/5 * * * (see here).
If you just want to open the webpage for 3 minutes, your workflow run step could use the && chaining the URL-opening command (xdg-open www.example.com can be used to open a URL) with a sleep 360. I leave the actual composition of the workflow file as an exercise to the reader 🙂.

Related

How to access GitHub action output in a badge

I have a GitHub action workflow that outputs a number and I want to display that in a badge.
Using https://github.com/username/reponame/actions/workflows/myaction.yml/badge.svg I get a red or green failing/success badge but I want to display the number of failures instead, which the workflow outputs into the "errors" output variable.
How can I access that variable in a badge?
There are few options in Github actions marketplace
Bring Your Own Badge - https://github.com/marketplace/actions/bring-your-own-badge
BYOB is a GitHub Action to create badges dynamically based off of GitHub Actions' results, allowing for extremely versatile and easily-maintainable badges.
If you want to use https://shields.io/, consider Dynamic Badges - https://github.com/marketplace/actions/dynamic-badges
This action allows you to create badges for your README.md with shields.io which may change with every commit. To do this, this action does not need to push anything to your repository!
In a subsequent job (step) in the same workflow you could.
I think you want to use your own badge using e.g. https://img.shields.io.
I image you will update e.g. the README file every time the actions are finished, the updating step will be part of the workflow. The transfer of output could be done like here Using output from a previous job in a new one in a GitHub Action.
You will append e.g. the README with a proper svg [![](https://img.shields.io/badge/TEXT-NUMBER-COLOR?style=flat)](some url).
I created an action to generate a badge from a workflow:
Build-A-Badge - https://github.com/marketplace/actions/build-a-badge
As other users have pointed out, I didn't want any external dependencies or to create new branches on the main repo. So the workaround I used is to store the badge data in the Wiki, which is a separate repository.

How do I know my Foundry Job is using AQE?

I hear people mention this AQE feature sometimes and I'm wondering how to verify if my job is using it or not. I'm running transformations both in Code Repositories and Code Workbooks.
This is noted in the Environment details tab of a job.
Navigate to Builds page
Find your running Build in the Build page. Click on it.
Find your relevant Job inside your Build's page. Click on it.
In the expanded view under your Job, click on the Spark Details button
Click on the Environment tab
Look for a row for adaptiveExecutionEnabled. If true, you are using AQE. If false then you are not.

Learning Applescript: Trouble linking to Safari

Run Down
Hello, this is a very specific and situation question. Basically, I'm running Applescript in Automator on Safari, and the result is Null.
What I Have
I currently have a script that can do these things:
Before I even run the Automator program, I have Safari open
Next I run the Automator, which starts with this code:
on run {input, parameters}
tell application "Safari" to activate
tell application "System Events"
keystroke "t" using command down
end tell
return input
end run
This script will activate Safari, and open a new tab.
Next I have an Automator pause. This will give the page time to load
After the Safari page has opened, I run this code:
on run
clickID("75610556")
end run
on clickID(theId)
tell application "Safari"
do JavaScript "document.getElementById(‘” & theId & “‘).click();" in document 1
end tell
end clickID
This script should of selected the button with the ID "75610556", but it did not. This is the key problem with my program.
Next I run the following code:
on run {input, parameters}
tell application "Safari" to activate
tell application "System Events"
keystroke "w" using command down
end tell
return input
end run
This closes the current tab.
Next, I loop through with an Automator loop.
What I Would Like Help With
I will address my questions for the program step by step.
For step one, is this a good way to set things up? Is Automator even a proper way to go?
Is this code efficient? Any errors yet?
I really hope there is an alternative to this. I have not found one.
Why won't this work in Safari? I feel like I have done this right.
Same as number 2, just curious if this is the best way to handle this
I think this is a good way to do things.
Why I Need This + Every Single Detail (Optional Section)
These are extra details if you want them. It will give you nearly every detail, and explain why I need this.
So there is a business contest at my college. I'm a freshman programmer, and have programmed a very simple mobile networking game. The issue is there is a cash prize foe $3,000 on a poll website. This website is Poll Everywhere. The judges did not realize that this website is not secure in the slightest. We reported it, and the judges thought it was not good enough of a reason to cancel the poll and maybe search for a new alternative. We reported that Poll Everywhere can be manipulated to work to any teams advantage who was smart enough to:
A. Turn off cookies for their browser
B. Use a private browser
But of course, the judges did not listen. They thought that if somebody stayed up all night, it might change it, but during a 2-3 hour period, it will have little effect. To deter their ruling, I would like to make an example program for them on my Mac that will blow their minds: A voting program. This program will open safari. Safari has already been configured to open the voting page in private browser mode. All my program has to do is open a new tab, find the button ID, and click on it. The faster it does this the better.
Final note: Was the back story too much? I know Stack overflow has a "spare the details" policy. I thought the elaborate version might help, but if it is a bad thing I will remove it.
Unfortunately I don't have a lot of time to answer all your questions as it's late and I need to get to bed, but here is an example of all you need to do. No need for automator, that just seems to complicate your process to me.
You may want to tweak some of the sleep settings a little if you need more "wait" time, I tried this on my local web server and it worked, but it's local so the site loads very fast.
on run
set i to 1
repeat until i > 5
do shell script "sleep 2"
tell application "Safari"
activate
tell window 1
set properties of current tab to {URL:"http://yoururl.com"}
end tell
end tell
do shell script "sleep 3"
tell application "Safari"
tell document 1
do JavaScript "document.getElementById(\"75610556\").click();"
end tell
quit
end tell
set i to i + 1
end repeat
end run
Also note, you'll need to change the url to your url where it says "http://yoururl.com" and you'll probably want to change the 5 in repeat until i > 5 to a larger number to let it repeat more.

Run build on change but don't checkout in Hudson

I have kind of an interesting problem...
So I'm trying to run a build every time I see a change on a directory in my SCM in Hudson. However, I don't need to pull the directory to run my script. Is there any way to check if there's a change in a directory, but don't pull it?
In addition, there is another directory which I do need to pull from Hudson at the same time. So basically I want something like:
On change of directory A or B:
pull directory B only
run script
I was told there was functionality like this in Hudson, but I can't find it. Any suggestions? Thanks for the help!
In case anyone is interested, I was able to accomplish this with just Hudson and Perforce.
When using Perforce as the SCM (don't know about the others) there is a 'Use View Mask' checkbox. Checking that give you the ability to choose which directories/files in Perforce to poll without actually pulling those files. For example, I had in my view:
//depot/my_script
I didn't want my script to run automatically when I had a new version, so I put it int o the "Poll Exclude File(s) text box:
//depot/my_script
Which pulls the latest version of my script. Then I checked the Use View Mask checkbox and put:
//depot/my_code_to_compile/
into the View Mask box.
To make Perforce poll for changes, I just checked the "Poll SCM" in build triggers and then made it check every minute. (by inserting "* * * * *" into the Scheduler box)
So to sum up, with the variables set as above, my Hudson job had the following behavior:
check for changes every minute
On changes to //depot/my_code_to_compile/, the Hudson job will run
On changes to //depot/my_script, nothing will happen
The job will pull changes to my_script, but will download nothing from //depot/my_code_to_compile/.
I think you need to install the FSTrigger Plugin for this functionality. To what the wiki pages show this is supported in Jenkins, I am not sure about Hudson compatibility.

http/html/ajax: show result before site is completely processed

I am looking for a way to show in a webapp in front of a task a wait-message and after it hide the message. The task is running a longer time. I dont know if it is possible at all.
The problem is, so far I can see, that the site will be returned to the users browser AFTER the task is completed because the task is part of the site as a inline code replaces by the webserver interpreter (no matter if PHP, Perl or whatever).
The only solution I can imagine is to parallel the task with threads or processes and requery the state with ajax in the website.
Any idea to do it less complex? Thanks for help!
The server should start sending content to the browser as soon as your code starts executing; it does not wait for the server-side code to finish first.
Therefore, you can just run the task after rendering the HTML containing the wait message. After the task, you can render a <script> block that hides the wait message.
See Watching long processes through CGI. You could adapt the same technique to display updates using AJAX calls.
Several ways you can do this:
1) Pull the task out into its own file so it isn't inline. Then use asynchronous AJAX to query the task. Display a progress bar on firing of the event, and hide it when it is done.
2) Make sure you are streaming your data back to the browser (This is the default in php.). If you are running php as a CGI it will execute the whole script before returning anything to the browser. In this case you will have to o #1 Put the inline task as the LAST thing on the page. In the place where the inline task is now, put up a <div id=loading>Content Loading Please Wait</div> or spinner/progress bar.
Capture the output of the inline task into a php variable At the end of the task add <script>document.getElementById('loading').innerHTML ="$taskResult";</script>