Skip to content

Commit

Permalink
updates add ops actions
Browse files Browse the repository at this point in the history
  • Loading branch information
saxix committed Jun 11, 2024
1 parent 948b950 commit e1e1dfc
Show file tree
Hide file tree
Showing 10 changed files with 592 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_workflows/*
21 changes: 21 additions & 0 deletions .github/actions/distro_hash/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# ref: https://docs.github.com/en/actions/creating-actions/creating-a-docker-container-action
name: 'Calculate Release Hash'
description: 'Calculate deps and os hash'
inputs:
files:
description: 'Files to use to calculate the hash'
required: true
default: "pdm.lock docker/bin/* docker/conf/* docker/Dockerfile"
outputs:
hash: # id of output
description: 'The time we greeted you'
value: ${{ steps.calc.outputs.hash }}

runs:
using: 'composite'
steps:
- id: calc
shell: bash --noprofile --norc -eo pipefail -ux {0}
run: |
LOCK_SHA=$(sha1sum ${{ inputs.files }} | sha1sum | awk '{print $1}' | cut -c 1-8)
echo "hash=$LOCK_SHA" >> "$GITHUB_OUTPUT"
54 changes: 54 additions & 0 deletions .github/actions/docker_build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# ref: https://docs.github.com/en/actions/creating-actions/creating-a-docker-container-action
name: 'Calculate version hash'
description: 'Calculate deps and os hash'
inputs:
username:
description: ''
required: true
password:
description: ''
required: true
image:
description: ''
required: true
target:
description: ''
required: true


runs:
using: 'composite'
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
tags: ${{vars.DOCKER_IMAGE}}:dev-latest
file: ./docker/Dockerfile
platforms: linux/amd64
cache-from: type=registry,ref=${{vars.DOCKER_IMAGE}}:dev-latest
cache-to: type=inline
outputs: type=registry
target: python_dev_deps
build-args: |
BUILD_DATE="${{ steps.build_date.outputs.date }}"
CHECKSUM="${{ steps.release_hash.outputs.hash }}"
VERSION="${{ steps.version.outputs.version }}"
- name: Calculate Release Hash
id: calc
shell: bash --noprofile --norc -eo pipefail {0}
run: |
docker pull ${{inputs.image}}
echo "----------"
docker inspect --format='{{json .Config.Labels}}' ${{inputs.image}}}}:dev-latest
docker run -t ${{inputs.image}}}}:dev-latest release-info.sh
echo "----------"
34 changes: 34 additions & 0 deletions .github/actions/docker_info/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# ref: https://docs.github.com/en/actions/creating-actions/creating-a-docker-container-action
name: 'Retrieve Docker Image Information'
description: 'Calculate deps and os hash'
inputs:
image:
description: 'Files to use to calculate the hash'
required: true
username:
description: ''
required: true
password:
description: ''
required: true

runs:
using: 'composite'
steps:
# - name: Configure Git
# shell: bash
# run: git config --global --add safe.directory $(realpath .)
# - name: ch
# uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: docker/login-action@v3
with:
username: ${{ inputs.username }}
password: ${{ inputs.password }}
- name: Calculate Release Hash
shell: bash
run: |
docker pull ${{inputs.image}}
echo "----------"
docker inspect --format='{{json .Config.Labels}}' ${{inputs.image}}
docker run -t ${{inputs.image}} release-info.sh
echo "----------"
51 changes: 51 additions & 0 deletions .github/actions/env/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: 'version'
description: ''

outputs:
stage:
description: ''
value: ${{ steps.version.outputs.stage }}
version:
description: ''
value: ${{ steps.version.outputs.version }}
commit:
description: ''
value: ${{ steps.version.outputs.commit }}
release:
description: ''
value: ${{ steps.version.outputs.release }}
date:
description: ''
value: ${{ steps.build_date.outputs.date }}
today:
description: ''
value: ${{ steps.build_date.outputs.today }}
timestamp:
description: ''
value: ${{ steps.build_date.outputs.timestamp }}
branch:
description: ''
value: ${{ steps.extract_branch.outputs.branch }}


runs:
using: 'composite'
steps:
- shell: bash --noprofile --norc -eo pipefail {0}
run: git config --global --add safe.directory $(realpath .)
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- id: version
uses: ./.github/actions/version
- id: extract_branch
name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
- id: build_date
shell: bash --noprofile --norc -eo pipefail -ux {0}
run: |
d1=$(date +"%a,%e %b %Y %H:%M %Z")
d2=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
d3=$(date -u +"%Y%m%d%H%M%S")
echo "today=$d1" >> $GITHUB_OUTPUT
echo "date=$d2" >> $GITHUB_OUTPUT
echo "timestamp=$d3" >> $GITHUB_OUTPUT
Loading

0 comments on commit e1e1dfc

Please sign in to comment.