add project accessories and public workflow dispatch option #3
This file contains hidden or 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
| --- | |
| # yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json | |
| name: Build and publish bash image | |
| on: # yamllint disable-line rule:truthy | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - bash/* | |
| - .github/workflows/publish-bash.yaml | |
| workflow_dispatch: | |
| env: | |
| DOCKER_USERNAME: brettinternet | |
| IMAGE_NAME: bash | |
| DESCRIPTION: An Alpine image for scripting with bash, curl and git using a dumb-init entrypoint | |
| defaults: | |
| run: | |
| working-directory: ./bash | |
| jobs: | |
| build-and-push-image: | |
| runs-on: ubuntu-latest | |
| if: "!contains(github.event.head_commit.message, 'skipci')" | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v1 | |
| with: | |
| platforms: arm64,amd64 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v2 | |
| - name: Log in to the Container registry | |
| uses: docker/login-action@v2 | |
| with: | |
| username: ${{ env.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_HUB_PAT }} | |
| - name: Log in to the Container registry | |
| uses: docker/login-action@v2 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract image metadata | |
| id: meta | |
| uses: docker/metadata-action@v4 | |
| with: | |
| images: | | |
| ${{ env.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }} | |
| ghcr.io/${{ github.actor }}/${{ env.IMAGE_NAME }} | |
| flavor: latest=auto | |
| tags: type=raw,value=latest,enable={{is_default_branch}} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v3 | |
| with: | |
| context: ./${{ env.IMAGE_NAME }} | |
| file: ./${{ env.IMAGE_NAME }}/Dockerfile | |
| platforms: arm64,amd64 | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: | | |
| org.opencontainers.image.name=${{ env.IMAGE_NAME }} | |
| org.opencontainers.image.source=https://github.com/brettinternet/containers/tree/main/${{ env.IMAGE_NAME }} | |
| org.opencontainers.image.description=${{ env.DESCRIPTION }} | |
| org.opencontainers.image.licenses=MIT | |
| - name: Update Docker Hub Description | |
| uses: peter-evans/dockerhub-description@v3 | |
| with: | |
| username: ${{ env.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_HUB_PAT }} | |
| repository: ${{ env.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }} | |
| short-description: ${{ env.DESCRIPTION }} | |
| readme-filepath: ./${{ env.IMAGE_NAME }}/README.md |