v2.18.0 #201
Workflow file for this run
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: Publish | |
on: | |
push: | |
branches: | |
- master | |
release: | |
types: [published] | |
env: | |
IMAGE_NAME: codeql | |
CONTAINER_REGISTRY_HOST: ghcr.io | |
jobs: | |
compile: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
code_language: [none, cpp, csharp, csv, go, html, java, javascript, properties, python, xml] | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: FranzDiebold/github-env-vars-action@v2 | |
- name: Log into registry | |
run: echo "${{ secrets.PAT }}" | docker login $CONTAINER_REGISTRY_HOST -u $CI_REPOSITORY_OWNER --password-stdin | |
- name: Set build variables | |
id: build | |
run: | | |
BRANCH=$(echo ${GITHUB_REF#refs/heads/}) | |
IMAGE_ID=$CONTAINER_REGISTRY_HOST/$CI_REPOSITORY_OWNER/$IMAGE_NAME | |
# Change all uppercase to lowercase | |
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') | |
# Strip git ref prefix from version | |
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') | |
# Strip "v" prefix from tag name | |
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') | |
[ "$VERSION" == "master" ] && VERSION=$(curl https://api.github.com/repos/github/codeql-cli-binaries/releases/latest | jq -r '.tag_name' | sed -e 's/^v//') | |
TAG="${{ matrix.code_language }}-$VERSION" | |
if [ "${{ matrix.code_language }}" == "none" ]; then | |
TAG="$VERSION" | |
fi | |
echo BRANCH=$BRANCH | |
echo IMAGE_ID=$IMAGE_ID | |
echo VERSION=$VERSION | |
echo TAG=$TAG | |
echo ::set-output name=branch::${BRANCH} | |
echo ::set-output name=image_id::${IMAGE_ID} | |
echo ::set-output name=version::${VERSION} | |
echo ::set-output name=tag::${TAG} | |
- name: Fetch cached image | |
run: >- | |
docker pull ${{ steps.build.outputs.image_id }}:${{ steps.build.outputs.tag }} || true | |
- name: Build image | |
run: >- | |
docker build . | |
--file Dockerfile | |
--tag $IMAGE_NAME | |
--cache-from ${{ steps.build.outputs.image_id }}:${{ steps.build.outputs.tag }} | |
--label "org.opencontainers.image.revision=$GITHUB_SHA" | |
--label "org.opencontainers.image.source=https://github.com/${{ github.repository }}" | |
--label "org.opencontainers.image.created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" | |
--label "org.opencontainers.image.description=CodeQL Docker for ${{ matrix.code_language }}" | |
--label "com.github.repo.dockerfile=Dockerfile" | |
--label "com.github.repo.branch=${{ steps.build.outputs.branch }}" | |
--build-arg CLI_VERSION=${{ steps.build.outputs.version }} | |
--build-arg CODE_LANGUAGE=${{ matrix.code_language }} | |
- name: Push image | |
run: | | |
docker tag $IMAGE_NAME ${{ steps.build.outputs.image_id }}:${{ steps.build.outputs.tag }} | |
if [ ${{ github.event_name }} == "release" ]; then | |
if [ ${{ matrix.code_language }} == "none" ]; then | |
docker tag $IMAGE_NAME ${{ steps.build.outputs.image_id }}:latest | |
else | |
docker tag $IMAGE_NAME ${{ steps.build.outputs.image_id }}:${{ matrix.code_language }} | |
fi | |
fi | |
docker push -a ${{ steps.build.outputs.image_id }} |