Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
2cd8a2b
Add PostgreSQL Docker workflow and Dockerfile
Sep 15, 2025
3884f1d
Create greetings.yml
MickeyGithubL Sep 15, 2025
3bc1ace
Create PostgreSQL image
MickeyGithubL Sep 16, 2025
4cce865
move these to save them for later
MickeyGithubL Sep 16, 2025
aeb3c7c
add schedule workflow
MickeyGithubL Sep 16, 2025
ec5b557
multi event template
MickeyGithubL Sep 16, 2025
f9a92cd
manual workflow
MickeyGithubL Oct 9, 2025
f76f9e6
add webhook
MickeyGithubL Oct 9, 2025
3069aa2
does this trigger?
MickeyGithubL Oct 9, 2025
0ca29b3
custom webhook
MickeyGithubL Oct 9, 2025
42aa031
sadsdasda
MickeyGithubL Oct 9, 2025
6dc8f70
fix this syntax
MickeyGithubL Oct 9, 2025
2b94f66
fix syntax
MickeyGithubL Oct 9, 2025
4c7a9d9
try again x2
MickeyGithubL Oct 17, 2025
a933c5c
try again this time
MickeyGithubL Oct 17, 2025
627e7ab
try now
MickeyGithubL Oct 17, 2025
f8a7030
conditional
MickeyGithubL Oct 17, 2025
4ea3192
conditional
MickeyGithubL Oct 17, 2025
d59b1d1
expression function example
MickeyGithubL Oct 17, 2025
88df31b
xxxxdddfff
MickeyGithubL Oct 17, 2025
6da87a1
dfbdfgsnthdgj
MickeyGithubL Oct 17, 2025
474ce44
try and fix expressions
MickeyGithubL Oct 17, 2025
ccc16ac
expression function
MickeyGithubL Oct 17, 2025
4f56710
try expression again
MickeyGithubL Oct 17, 2025
a600fa8
runners for macos and windows
MickeyGithubL Oct 17, 2025
65b1848
commit self hosted runner
MickeyGithubL Oct 28, 2025
ca0f5f4
workflow commands example
MickeyGithubL Oct 28, 2025
d0ce29c
Add workflow commands workflow file
MickeyGithubL Oct 28, 2025
7a82432
env var in other steps
MickeyGithubL Oct 28, 2025
408095a
Fix shell quoting in workflow-command.yml steps
MickeyGithubL Oct 28, 2025
d4e5877
attempt context
MickeyGithubL Oct 28, 2025
dbea1fd
Fix run command formatting in context.yml
MickeyGithubL Oct 28, 2025
c0dccff
jobs workflow example
MickeyGithubL Oct 28, 2025
0e38f27
Fix and improve jobs.yml workflow
MickeyGithubL Oct 28, 2025
7716d9d
try again
MickeyGithubL Oct 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/workflows/context.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Context Examples

on:
push:
branches: [ main ]

jobs:
context-job:
runs-on: ubuntu-latest
steps:
- name: "My Step"
run: |
echo "Action! $MY_ACTION"
echo "Actor! $MY_ACTOR"
env:
MY_ACTION: ${{ github.action }}
MY_ACTOR: ${{ github.actor }}

15 changes: 0 additions & 15 deletions .github/workflows/custom-action.yml

This file was deleted.

20 changes: 20 additions & 0 deletions .github/workflows/jobs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: "Dependent Jobs Example"

on:
push:
branches: [ main ]
workflow_dispatch: # Allow manual triggering

jobs:
job2:
runs-on: ubuntu-latest
steps:
- name: StepA"
run: |
echo "World"
job1:
runs-on: ubuntu-latest
steps:
- name: StepB
run:
echo "Hello"
22 changes: 22 additions & 0 deletions .github/workflows/workflow-command.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: "Workflow Commands"

on:
push:
branches: [ main ]

jobs:
my-job:
runs-on: ubuntu-latest
steps:
- name: "group logging"
run: |
echo "::group::My Group Message"
echo "Msg1"
echo "Msg2"
echo "::endgroup::"
- name: "step 1"
run: |
echo "MY_VAL=hello" >> "$GITHUB_ENV"
- name: "step 2"
run: |
echo "$MY_VAL"
2 changes: 1 addition & 1 deletion github-actions/Readme.me
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ echo '{"name":"mona", "greeting":"hello"}' | gh workflow run greet.yml --json
```

## Webhook Event

```sh
curl -X POST \
-H "Accept: application/vnd.github+json" \
Expand Down
1 change: 1 addition & 0 deletions github-actions/mydata2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SGVsbG8gTWFycw==
34 changes: 34 additions & 0 deletions github-actions/templates/PostgreSQL image
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# filepath: .github/workflows/postgres-image.yml
name: PostgreSQL Docker Workflow

on:
push:
paths:
- 'docker/**'
- '.github/workflows/postgres-image.yml'

jobs:
postgres:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:latest
env:
POSTGRES_USER: myuser
POSTGRES_PASSWORD: mypassword
POSTGRES_DB: mydatabase
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
- name: Wait for PostgreSQL to be ready
run: |
for i in {1..30}; do
pg_isready -h localhost -p 5432 -U myuser && break
sleep 2
done
36 changes: 36 additions & 0 deletions postgresql-workflow-example/.github/workflows/postgres-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Build and Push PostgreSQL Docker Image

on:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# Ensure that DOCKER_USERNAME and DOCKER_PASSWORD are set in your repository's secrets at
# https://github.com/<owner>/<repo>/settings/secrets/actions

- name: Build PostgreSQL Docker image
uses: docker/build-push-action@v2
with:
context: ./docker
file: ./docker/Dockerfile
push: true
tags: your-dockerhub-username/postgres-image:latest

- name: Logout from Docker Hub
run: docker logout
57 changes: 57 additions & 0 deletions postgresql-workflow-example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# PostgreSQL Workflow Example

This project demonstrates how to build and push a PostgreSQL Docker image using GitHub Actions. It includes a Dockerfile for creating the PostgreSQL image and a GitHub Actions workflow for automating the build and push process.

## Project Structure

```
postgresql-workflow-example
├── .github
│ └── workflows
│ └── postgres-image.yml # GitHub Actions workflow for building and pushing the Docker image
├── docker
│ └── Dockerfile # Dockerfile for PostgreSQL image
├── src
│ └── app.js # Main application file for connecting to the PostgreSQL database
├── package.json # npm configuration file
└── README.md # Project documentation
```

## Getting Started

To get started with this project, follow these steps:

1. **Clone the repository**:
```bash
git clone <repository-url>
cd postgresql-workflow-example
```

2. **Build the Docker image**:
Navigate to the `docker` directory and build the image using the Dockerfile:
```bash
cd docker
docker build -t your-postgres-image-name .
```

3. **Run the Docker container**:
After building the image, you can run it with:
```bash
docker run --name your-container-name -e POSTGRES_PASSWORD=yourpassword -d your-postgres-image-name
```

## GitHub Actions Workflow

The GitHub Actions workflow defined in `.github/workflows/postgres-image.yml` automates the process of building and pushing the Docker image to a container registry whenever changes are pushed to the main branch.

## Usage

You can connect to the PostgreSQL database using the credentials specified in the Docker run command. The main application logic can be found in `src/app.js`, where you can implement your database operations.

## Contributing

Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.

## License

This project is licensed under the MIT License. See the LICENSE file for more details.
9 changes: 9 additions & 0 deletions postgresql-workflow-example/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM postgres:latest

ENV POSTGRES_USER=myuser
ENV POSTGRES_PASSWORD=mypassword
ENV POSTGRES_DB=mydatabase

COPY init.sql /docker-entrypoint-initdb.d/

EXPOSE 5432
27 changes: 27 additions & 0 deletions postgresql-workflow-example/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "postgresql-workflow-example",
"version": "1.0.0",
"description": "A project to demonstrate building and pushing a PostgreSQL Docker image using GitHub Actions.",
"main": "src/app.js",
"scripts": {
"start": "node src/app.js",
"test": "echo \"No tests specified\" && exit 0"
},
"dependencies": {
"pg": "^8.7.1"
},
"devDependencies": {
"nodemon": "^2.0.15"
},
"repository": {
"type": "git",
"url": "https://github.com/yourusername/postgresql-workflow-example.git"
},
"keywords": [
"postgresql",
"docker",
"github-actions"
],
"author": "Your Name",
"license": "MIT"
}
33 changes: 33 additions & 0 deletions postgresql-workflow-example/src/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const express = require('express');
const { Pool } = require('pg');

const app = express();
const port = process.env.PORT || 3000;

// PostgreSQL connection configuration
const pool = new Pool({
user: process.env.DB_USER,
host: process.env.DB_HOST,
database: process.env.DB_NAME,
password: process.env.DB_PASSWORD,
port: process.env.DB_PORT,
});

// Middleware to parse JSON requests
app.use(express.json());

// Example route to get data from the database
app.get('/data', async (req, res) => {
try {
const result = await pool.query('SELECT * FROM your_table_name');
res.status(200).json(result.rows);
} catch (err) {
console.error(err);
res.status(500).send('Server error');
}
});

// Start the server
app.listen(port, () => {
console.log(`Server is running on port ${port}`);
});