Skip to content

Wf upgrade

Wf upgrade #19

Workflow file for this run

on:
pull_request:
types:
- closed
env:
REGISTRY: ghcr.io
IMAGE_NAME: w6d-io/process-rest
jobs:
build:
runs-on: ubuntu-latest
if: ${{ contains(github.event.pull_request.labels.*.name, 'release') &&github.event.pull_request.merged}}
permissions:
id-token: write
contents: write
packages: write
attestations: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: Build variables
id: build_env
run: |
echo "BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")" >> $GITHUB_ENV
echo "PROJECT_URL=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}" >> $GITHUB_ENV
echo "VCS_REF=$GITHUB_SHA" >> $GITHUB_ENV
- name: Generate tag
id: generate_tag
uses: K-Phoen/semver-release-action@master
with:
release_branch: main
release_strategy: none
env:
GITHUB_TOKEN: ${{ secrets.WF_TOKEN }}
- name: Login to Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}}
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
- name: Build and push Docker image
id: push
uses: docker/build-push-action@v5
with:
context: .
push: true
build-args: |
VERSION=${{ steps.generate_tag.outputs.tag }}
VCS_REF=${{ env.VCS_REF }}
BUILD_DATE=${{ env.BUILD_DATE }}
PROJECT_URL=${{ env.PROJECT_URL }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Set up Git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git tag ${{ steps.generate_tag.outputs.tag }}
- name: Push tag
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.WF_TOKEN }}
tags: true
push_only_tags: true