-
Notifications
You must be signed in to change notification settings - Fork 0
58 lines (57 loc) · 1.78 KB
/
pgcli.yml
File metadata and controls
58 lines (57 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
name: Build pgcli docker image
on:
push:
branches:
- main
paths:
- '.github/workflows/pgcli.yml'
- 'pgcli/'
- '!**/README.md'
schedule:
# Check if new version is available every Monday at 00:00
- cron: "0 0 * * 1"
workflow_dispatch:
jobs:
should-build:
runs-on: ubuntu-latest
outputs:
should_build: ${{ steps.check.outputs.should_build }}
pgcli_version: ${{ steps.check.outputs.pgcli_version }}
steps:
- uses: actions/checkout@v4
- uses: jorgebg/stateful-action@v0.3
- name: Check if pgcli has a new version on PyPI
id: check
run: |
STATE_VERSION=$(cat .state/pgcli_version || true)
LATEST_VERSION=$(curl -s https://pypi.org/pypi/pgcli/json | jq -r '.info.version')
echo "pgcli_version=$LATEST_VERSION" >> $GITHUB_OUTPUT
if [[ "$STATE_VERSION" != "$LATEST_VERSION" || "${{ github.event_name }}" != "schedule" ]]; then
echo "should_build=true" >> $GITHUB_OUTPUT
else
echo "should_build=false" >> $GITHUB_OUTPUT
fi
build-and-push:
needs:
- should-build
if: ${{ needs.should-build.outputs.should_build == 'true' }}
permissions:
contents: read
packages: write
uses: ./.github/workflows/build.template.yml
with:
docker_image: ghcr.io/d34dplayer/pgcli
dockerfile: pgcli/Dockerfile
version: ${{ needs.should-build.outputs.pgcli_version }}
update-state:
needs:
- should-build
- build-and-push
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: jorgebg/stateful-action@v0.3
- name: Update state
run: printf "${{ needs.should-build.outputs.pgcli_version }}" > .state/pgcli_version