Why does my github actions keep changing to the repo with the latest commit push, how…
- User
Why does my github actions keep changing to the repo with the latest commit push, how can i set it to only deploy when main has recent pushes?
- Assistant
To ensure that your Github Action workflow only deploys when there are recent pushes to the main branch, you need to add a trigger condition in the workflow file. A trigger condition is used to specify when a particular workflow should be triggered.
You can add the following code at the beginning of your workflow file to specify that the workflow should only run on the main branch and when there are recent pushes:
on: push: branches: - main # only run for recent pushes paths-ignore: - README.md # specify any file or directory to ignore # only run for pushes within the last 3 days if: github.event.pushed_at >= (github.event.head_commit.timestamp | subtract(259200))This code specifies that the workflow only runs on the main branch, ignores pushes that modify the README.md file, and only runs for pushes within the last three days. You can adjust these parameters to suit your needs.
By adding this trigger condition, the workflow will only run when there are recent pushes to the main branch, and not for other branches with the latest commit push.
- User
Teach me enough prisma so i am comfortable with it
- Assistant
- User
Now give me an exmaple of 3 or 4 related schemas and teach me about where, include , select and other most used schema properties
- Assistant
- User
Write a query using the above schema and include select where properties
- Assistant
Sure, here's an example query that uses the above schema and includes the
@selectand@wheredirectives:const { PrismaClient } = require('@prisma/client') const prisma = new PrismaClient() async function getUsersWithComments() { const users = await prisma.user.findMany({ select: { id: true, name: true, email: true, comments: { select: { id: true, text: true, createdAt: true, post: { select: { id: true, title: true } } }, where: { createdAt: { gt: new Date('2022-01-01T00:00:00.000Z') } } } }, where: { name: { contains: 'John' } } }) console.log(users) } getUsersWithComments()This query fetches all users whose name contains the string 'John' and their associated comments, but only selects specific fields from each data model. It also includes a
@wheredirective on thecommentsfield to fetch comments created after January 1st, 2022.As you can see, Prisma's declarative syntax allows you to write complex queries with ease and makes it possible to fetch related data in a single query.
- User
How do i ssh into an ubuntu server from windows if have a public key , username and ip
- Assistant
To SSH into an Ubuntu server from Windows using a public key, username, and IP address, you will need an SSH client. Here are the steps to SSH into the server:
-
Download an SSH client like PuTTY from the official website https://www.putty.org/.
-
Once you have downloaded PuTTY, open it and you should see a screen with a field "Host Name" that you can enter the server's IP address.
-
Next, navigate to the "Connection" -> "SSH" tab on the left pane. Under this tab, you will see "Auth" option, click on it.
-
In the "Authentication Parameters" section of the "PuTTY Configuration" window, click the "Browse" button next to "Private key file for authentication" and select the private key file that corresponds to the public key that you have added to the server. Note that the key file must be in the PuTTY's format.
-
- User
What about from ubuntu os
- Assistant
If you are using Ubuntu OS, you can directly use the terminal to SSH into an Ubuntu server using a public key, username, and IP address. Here are the steps to SSH into the server:
-
Open the terminal on your Ubuntu machine.
-
Use the
sshcommand followed by the username and IP address of the server, like this:
ssh username@ip_address-
If this is the first time you are connecting to the server, you will be prompted to add the server's public key to your
known_hostsfile. Type "yes" to continue. -
Next, you will be prompted for the passphrase for your private key (if you have set any). Enter the passphrase, if required.
-
Once you provide the passphrase, you should be logged into the remote server via SSH.
Note: Like I mentioned earlier, make sure that the SSH port (usually port 22) on the server is open in the firewall and accessible from your Ubuntu machine. If you face any issues with the SSH connection, try adding the
-voption to thesshcommand to troubleshoot the connection. The-voption will provide verbose output, which can help in diagnosing the issue. -
- User
How do add my public key to access from the terminal
- Assistant
To add your public key to an Ubuntu server to allow SSH access from the terminal, you need to follow these steps:
- Generate an SSH key pair on your local machine if you haven't already done so. You can do this by running the following command in your terminal:
ssh-keygen-
This will prompt you to enter a file name and passphrase for the key pair. You can simply press Enter to accept the defaults.
-
Once the key pair is generated, you need to copy the public key to the server by running the following command:
ssh-copy-id username@ip_addressMake sure to replace
usernameandip_addresswith the actual username and IP address of the server.-
This command will copy your public key to the server and add it to the
authorized_keysfile on the server, which allows you to log in without being prompted for a password. -
If you are prompted to enter your password during this process, enter your server password. Once you have entered the password, your public key will be copied to the server, and you should be able to log in without entering your password.
- User
What if there is one public key for all users ?
- Assistant
If there is a single public key that is used for all users to access an Ubuntu server via SSH, you can add the public key to the
/etc/ssh/sshd_configfile on the server. Here's how you can do it:-
Log in to the Ubuntu server as the root user or a user with sudo privileges.
-
Open the
/etc/ssh/sshd_configfile using your favorite text editor. For example, you can use the nano editor by running the following command:
sudo nano /etc/ssh/sshd_config- Scroll down to the bottom of the file and add the following line to allow logins using the public key:
AuthorizedKeysFile /etc/ssh/authorized_keys-
Save and close the
sshd_configfile. -
Create the
/etc/ssh/authorized_keysfile if it does not already exist by running the following command:
sudo touch /etc/ssh/authorized_keys -
- User
How can users login for the above scenario
- Assistant
For the scenario where there is a single public key that is used for all users to access an Ubuntu server, every user must have the matching private key on their local machine. Here are the steps for users to log in to the server via SSH:
-
The users must create an SSH key pair on their local machine using the
ssh-keygencommand. -
Once the key pair is generated, the user must copy their public key to the
/etc/ssh/authorized_keysfile on the server using thessh-copy-idcommand. This step would need to be performed by a user with sudo access on the server, since they would need to have permission to modify the/etc/ssh/authorized_keysfile. -
Once the public key is added to the
authorized_keysfile, the user can log in to the server via SSH by running the following command on their local machine:
ssh user@server_ip_addressReplace
userwith the actual username of the user on the server, and with the IP address of the server. -
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.