๐Ÿ“ฆ EqualifyEverything / dockerized-wappalyzer

๐Ÿ“„ containerize.yml ยท 50 lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50name: ๐Ÿ—๏ธ๐Ÿ“ค Build and publish ๐Ÿณ images

on:
  push:
   # branches: ["main"]    # Triggers the workflow when a push event is detected on any branch.

env:
  REGISTRY: ghcr.io    # Sets the container registry where the image will be published.
  IMAGE_NAME: ${{ github.repository }}    # Sets the name of the GitHub repository.

jobs:
  build-and-push-image:
    name: ๐Ÿ—๏ธ๐Ÿ“ค Build and push ๐Ÿณ image    # Names the job.
    runs-on: ubuntu-latest    # Specifies the operating system for the job.
    permissions:
      contents: read    # Gives the job read access to the repository contents.
      packages: write    # Gives the job write access to packages.

    steps:
      - name: ๐Ÿ‘€๐Ÿ“ฆ Checkout repository.    # Names the first step.
        uses: actions/checkout@v3    # Uses the "checkout" GitHub Action to check out the repository.

      - name: ๐Ÿ”‘๐Ÿ“ฆ Login to container registry    # Names the second step.
        uses: docker/login-action@v2.1.0    # Uses the "login-action" GitHub Action to log into the container registry.
        with:
          registry: ${{ env.REGISTRY }}    # Specifies the container registry.
          username: ${{ github.actor }}    # Specifies the username.
          password: ${{ secrets.GITHUB_TOKEN }}    # Specifies the password.

      - name: ๐Ÿ”๐Ÿ“ Extract metadata (๐Ÿท๏ธ, ๐Ÿท๏ธ) for ๐Ÿณ    # Names the third step.
        id: meta    # Assigns an ID to the step.
        uses: docker/metadata-action@v4.3.0    # Uses the "metadata-action" GitHub Action to extract metadata for the Docker image.
        with:
          flavor: |    # Defines the flavor.
            latest=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}    # Sets the latest tag based on whether the push event is for the default branch.
          images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}    # Specifies the image name.
          tags: |    # Defines the tags.
            type=raw,value=latest,priority=100,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}    # Sets the "latest" tag for default branch
            type=sha,priority=400,enable=true,prefix={{branch}}-,suffix=,format=short    # Sets a tag with the branch name and a short commit hash.
            type=raw,prefix={{branch}}-,value=latest,priority=300,enable=${{ github.ref != format('refs/heads/{0}', github.event.repository.default_branch) }}


      - name: ๐Ÿ—๏ธ๐Ÿ“ค Build and push ๐Ÿณ image    # Names the fourth step.
        uses: docker/build-push-action@v4.0.0    # Uses the "build-push-action" GitHub Action to build and push the Docker image.
        with:
          context: .    # Specifies the build context as the current directory.
          push: true    # Specifies that the image should be pushed to the container registry.
          tags: ${{ steps.meta.outputs.tags }}    # Uses the tags output from the previous step.
          labels: ${{ steps.meta.outputs.labels }}    # Uses the labels output from the previous step.