Update PROJECT #32
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: | |
- main | |
- develop | |
- release* | |
tags: [v*] | |
paths-ignore: | |
- README.md | |
- CHANGELOG.md | |
- LICENSE | |
pull_request: | |
# Sequence of patterns matched against refs/heads | |
branches: | |
- main | |
- develop | |
- release* | |
paths-ignore: | |
- README.md | |
- CHANGELOG.md | |
- LICENSE | |
env: | |
IMAGE_NAME: 'operator' | |
jobs: | |
Operator: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: 'read' | |
id-token: 'write' | |
packages: 'write' | |
name: Operator | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: 'Get Previous tag' | |
id: previoustag | |
uses: "WyriHaximus/github-action-get-previous-tag@v1" | |
with: | |
fallback: 0.0.0 | |
- name: Set image tag | |
shell: bash | |
id: tags | |
run: | | |
if [[ ${{ github.ref_name }} =~ ^v.* ]] ; then | |
VERSION=${{ github.ref_name }} | |
echo "VERSION=${VERSION:1}" >> "${GITHUB_OUTPUT}" | |
else | |
VERSION=${{ steps.previoustag.outputs.tag }} | |
echo "VERSION=${VERSION:1}-${{ github.run_number }}" >> "${GITHUB_OUTPUT}" | |
fi | |
- name: Get image tag | |
run: | | |
echo ${{ steps.tags.outputs.VERSION }} | |
- uses: google-github-actions/setup-gcloud@94337306dda8180d967a56932ceb4ddcf01edae7 | |
with: | |
service_account_key: ${{ secrets.GKE_SA_KEY }} | |
project_id: ${{ env.PROJECT }} | |
- name: Login to Github Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: "ghcr.io" | |
username: ${{ github.actor }} | |
password: ${{ secrets.PAT }} | |
- name: Build and Push to ghcr | |
uses: docker/build-push-action@v3 | |
id: build_push_ghcr | |
with: | |
file: Dockerfile | |
push: true | |
outputs: type=image,name=target,annotation-index.org.opencontainers.image.description=operator | |
tags: | | |
ghcr.io/datasance/${{ env.IMAGE_NAME }}:${{ steps.tags.outputs.VERSION }} | |
ghcr.io/datasance/${{ env.IMAGE_NAME }}:latest | |
ghcr.io/datasance/${{ env.IMAGE_NAME }}:main | |
- run: mkdir -p ${{ github.workspace }}/artifact | |
- run: echo ${{ steps.tags.outputs.VERSION }} > ${{ github.workspace }}/artifact/version.txt | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: operator | |
path: ${{ github.workspace }}/artifact/version.txt |