Every function that is called on the blockchain is considered a transaction which means the gas-fee is applicable (unless the function is a view).
Deploying a smart contract is a transaction as well.
Mining the transactions
Transactions are mined by the miners:
- We broadcast our transaction
- Wait for it to be picked up by actual miners
- Wait for it to be mined
- Wait for it to be broadcasted back to the blockchain telling all the other miners to update their copies