Skip to content

chore: pin GitHub Actions to commit SHAs (#166) #121

chore: pin GitHub Actions to commit SHAs (#166)

chore: pin GitHub Actions to commit SHAs (#166) #121

name: Publish Latest Docker Image
permissions:
packages: write
contents: read
on:
push:
branches:
- main
env:
GO111MODULE: on
GOPRIVATE: github.com/sprintertech
ORG: 'sprintertech'
REGISTRY: 'ghcr.io'
TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }}
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
# Checkout the repository
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: setup git access to private repos
run: git config --global url."https://${TOKEN}:x-oauth-basic@github.com/sprintertech/".insteadOf "https://github.com/sprintertech/"
# Log in to GHCR
- name: Log in to GHCR
id: ghcr
uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4.0.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Build and push the Docker image
- name: Build and push Docker image
uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7.0.0
with:
context: .
push: true
# Pass build arguments for the GitHub credentials
secrets: |
GH_USER_NAME=${{ secrets.GH_USER_NAME }}
GH_USER_TOKEN=${{ secrets.GHCR_TOKEN }}
tags: |
${{ env.REGISTRY }}/${{ github.repository }}:latest