Skip to content

Commit

Permalink
ci: update GitHub Actions configs
Browse files Browse the repository at this point in the history
  • Loading branch information
engineervix committed Jun 26, 2023
1 parent 5a82540 commit cd97aa4
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 11 deletions.
53 changes: 50 additions & 3 deletions .github/workflows/build-docker-image.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
name: Build Docker images

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
push:
branches: [ "main" ]
tags:
- "v*"

jobs:

Expand All @@ -23,5 +25,50 @@ jobs:
run: |
docker build . \
--file Dockerfile \
--tag python-latex:${{ matrix.python-version }}-$(date +%s) \
--tag python-latex:${{ matrix.python-version }}-$(date +'%Y%m%d%H%M%S') \
--build-arg PYTHON_VERSION=${{ matrix.python-version }}
# Creates a GitHub Release when the build job succeeds, and only on pushes to tags.
release:
needs: [build]

permissions:
contents: write

if: needs.build.result == 'success' && startsWith( github.ref, 'refs/tags/v' )

runs-on: ubuntu-22.04

steps:
- name: Check out the repo
uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
cache: "npm"
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
npm ci
- name: Get the version
id: get_version
run: |
echo "${{ github.ref }}"
echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
- name: Generate Release Title
id: get_release_title
shell: bash
run: |
export TODAY="($(TZ=Africa/Lusaka date --iso))"
echo ::set-output name=RELEASE_NAME::"${{ steps.get_version.outputs.VERSION }} $TODAY"
- name: Extract Release Notes
# This creates a file LATEST_RELEASE_NOTES.md in the parent directory (../)
shell: bash
run: |
python3 utils/release.py notes
- name: GitHub Release
uses: softprops/action-gh-release@v1
with:
name: ${{ steps.get_release_title.outputs.RELEASE_NAME }}
body_path: ../LATEST_RELEASE_NOTES.md
26 changes: 18 additions & 8 deletions .github/workflows/publish-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,28 @@ jobs:
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Get current timestamp
id: timestamp
run: echo "::set-output name=timestamp::$(date +'%Y-%m-%dT%H:%M:%SZ')"

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@dbbf01822bb698575d92e1ee5b9229d58745b0c6
with:
images: engineervix/python-latex

- name: Get git commit SHA
id: git_sha
run: echo "::set-output name=git_sha::$(git rev-parse HEAD)"

- name: Build and push Docker image
uses: docker/build-push-action@f9efed53cc1b0364ba947400ac02042bbbaac7fc
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
tags: ${{ matrix.python-version }}
labels: |
"org.opencontainers.image.title": "python-latex",
"org.opencontainers.image.description": "Python ${{ matrix.python-version }}-slim-bullseye plus texlive and pandoc",
"org.opencontainers.image.url": "https://github.com/engineervix/docker-python-latex",
"org.opencontainers.image.source": "https://github.com/engineervix/docker-python-latex",
"org.opencontainers.image.version": "${{ matrix.python-version }}",
"org.opencontainers.image.licenses": "MIT"
"org.opencontainers.image.created": "${{ steps.timestamp.outputs.timestamp }}",
"org.opencontainers.image.revision": "${{ steps.git_sha.outputs.git_sha }}"
build-args: PYTHON_VERSION=${{ matrix.python-version }}

0 comments on commit cd97aa4

Please sign in to comment.